@types/react 18.0.36 → 18.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- react/README.md +1 -1
- react/experimental.d.ts +4 -0
- react/global.d.ts +1 -0
- react/index.d.ts +27 -5
- react/package.json +24 -2
- react/ts5.0/experimental.d.ts +108 -0
- react/ts5.0/global.d.ts +157 -0
- react/ts5.0/index.d.ts +3297 -0
- react/ts5.0/jsx-dev-runtime.d.ts +2 -0
- react/ts5.0/jsx-runtime.d.ts +2 -0
- react/ts5.0/next.d.ts +86 -0
react/ts5.0/next.d.ts
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
/**
|
2
|
+
* These are types for things that are present in the React `next` release channel.
|
3
|
+
*
|
4
|
+
* To load the types declared here in an actual project, there are three ways. The easiest one,
|
5
|
+
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
|
6
|
+
* is to add `"react/next"` to the `"types"` array.
|
7
|
+
*
|
8
|
+
* Alternatively, a specific import syntax can to be used from a typescript file.
|
9
|
+
* This module does not exist in reality, which is why the {} is important:
|
10
|
+
*
|
11
|
+
* ```ts
|
12
|
+
* import {} from 'react/next'
|
13
|
+
* ```
|
14
|
+
*
|
15
|
+
* It is also possible to include it through a triple-slash reference:
|
16
|
+
*
|
17
|
+
* ```ts
|
18
|
+
* /// <reference types="react/next" />
|
19
|
+
* ```
|
20
|
+
*
|
21
|
+
* Either the import or the reference only needs to appear once, anywhere in the project.
|
22
|
+
*/
|
23
|
+
|
24
|
+
// See https://github.com/facebook/react/blob/main/packages/react/src/React.js to see how the exports are declared,
|
25
|
+
|
26
|
+
import React = require('.');
|
27
|
+
|
28
|
+
export {};
|
29
|
+
|
30
|
+
declare module '.' {
|
31
|
+
interface ThenableImpl<T> {
|
32
|
+
then(onFulfill: (value: T) => unknown, onReject: (error: unknown) => unknown): void | PromiseLike<unknown>;
|
33
|
+
}
|
34
|
+
interface UntrackedThenable<T> extends ThenableImpl<T> {
|
35
|
+
status?: void;
|
36
|
+
}
|
37
|
+
|
38
|
+
export interface PendingThenable<T> extends ThenableImpl<T> {
|
39
|
+
status: 'pending';
|
40
|
+
}
|
41
|
+
|
42
|
+
export interface FulfilledThenable<T> extends ThenableImpl<T> {
|
43
|
+
status: 'fulfilled';
|
44
|
+
value: T;
|
45
|
+
}
|
46
|
+
|
47
|
+
export interface RejectedThenable<T> extends ThenableImpl<T> {
|
48
|
+
status: 'rejected';
|
49
|
+
reason: unknown;
|
50
|
+
}
|
51
|
+
|
52
|
+
export type Thenable<T> = UntrackedThenable<T> | PendingThenable<T> | FulfilledThenable<T> | RejectedThenable<T>;
|
53
|
+
|
54
|
+
export type Usable<T> = Thenable<T> | Context<T>;
|
55
|
+
|
56
|
+
export function use<T>(usable: Usable<T>): T;
|
57
|
+
|
58
|
+
interface ServerContextJSONArray extends ReadonlyArray<ServerContextJSONValue> {}
|
59
|
+
export type ServerContextJSONValue =
|
60
|
+
| string
|
61
|
+
| boolean
|
62
|
+
| number
|
63
|
+
| null
|
64
|
+
| ServerContextJSONArray
|
65
|
+
| { [key: string]: ServerContextJSONValue };
|
66
|
+
export interface ServerContext<T extends ServerContextJSONValue> {
|
67
|
+
Provider: Provider<T>;
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Accepts a context object (the value returned from `React.createContext` or `React.createServerContext`) and returns the current
|
71
|
+
* context value, as given by the nearest context provider for the given context.
|
72
|
+
*
|
73
|
+
* @version 16.8.0
|
74
|
+
* @see https://react.dev/reference/react/useContext
|
75
|
+
*/
|
76
|
+
function useContext<T extends ServerContextJSONValue>(context: ServerContext<T>): T;
|
77
|
+
export function createServerContext<T extends ServerContextJSONValue>(
|
78
|
+
globalName: string,
|
79
|
+
defaultValue: T,
|
80
|
+
): ServerContext<T>;
|
81
|
+
|
82
|
+
// tslint:disable-next-line ban-types
|
83
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
84
|
+
|
85
|
+
export function unstable_useCacheRefresh(): () => void;
|
86
|
+
}
|