@types/react 18.3.1 → 19.2.0
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 +3 -3
- react/canary.d.ts +0 -128
- react/compiler-runtime.d.ts +4 -0
- react/experimental.d.ts +115 -17
- react/global.d.ts +6 -0
- react/index.d.ts +548 -785
- react/package.json +9 -9
- react/ts5.0/canary.d.ts +0 -128
- react/ts5.0/experimental.d.ts +115 -17
- react/ts5.0/global.d.ts +6 -0
- react/ts5.0/index.d.ts +544 -781
react/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.2.0",
|
|
4
4
|
"description": "TypeScript definitions for react",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
|
|
6
6
|
"license": "MIT",
|
|
@@ -122,11 +122,6 @@
|
|
|
122
122
|
"githubUsername": "vhfmag",
|
|
123
123
|
"url": "https://github.com/vhfmag"
|
|
124
124
|
},
|
|
125
|
-
{
|
|
126
|
-
"name": "Dale Tan",
|
|
127
|
-
"githubUsername": "hellatan",
|
|
128
|
-
"url": "https://github.com/hellatan"
|
|
129
|
-
},
|
|
130
125
|
{
|
|
131
126
|
"name": "Priyanshu Rav",
|
|
132
127
|
"githubUsername": "priyanshurav",
|
|
@@ -169,6 +164,11 @@
|
|
|
169
164
|
"default": "./canary.d.ts"
|
|
170
165
|
}
|
|
171
166
|
},
|
|
167
|
+
"./compiler-runtime": {
|
|
168
|
+
"types": {
|
|
169
|
+
"default": "./compiler-runtime.d.ts"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
172
|
"./experimental": {
|
|
173
173
|
"types@<=5.0": {
|
|
174
174
|
"default": "./ts5.0/experimental.d.ts"
|
|
@@ -202,9 +202,9 @@
|
|
|
202
202
|
},
|
|
203
203
|
"scripts": {},
|
|
204
204
|
"dependencies": {
|
|
205
|
-
"@types/prop-types": "*",
|
|
206
205
|
"csstype": "^3.0.2"
|
|
207
206
|
},
|
|
208
|
-
"
|
|
209
|
-
"
|
|
207
|
+
"peerDependencies": {},
|
|
208
|
+
"typesPublisherContentHash": "c9a97f0f7c3420dded9204849fbe3d4fd1a547115618e12f5801b737d9b9fa61",
|
|
209
|
+
"typeScriptVersion": "5.2"
|
|
210
210
|
}
|
react/ts5.0/canary.d.ts
CHANGED
|
@@ -31,133 +31,5 @@ declare const UNDEFINED_VOID_ONLY: unique symbol;
|
|
|
31
31
|
type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
|
|
32
32
|
|
|
33
33
|
declare module "." {
|
|
34
|
-
interface ThenableImpl<T> {
|
|
35
|
-
then(onFulfill: (value: T) => unknown, onReject: (error: unknown) => unknown): void | PromiseLike<unknown>;
|
|
36
|
-
}
|
|
37
|
-
interface UntrackedThenable<T> extends ThenableImpl<T> {
|
|
38
|
-
status?: void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface PendingThenable<T> extends ThenableImpl<T> {
|
|
42
|
-
status: "pending";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface FulfilledThenable<T> extends ThenableImpl<T> {
|
|
46
|
-
status: "fulfilled";
|
|
47
|
-
value: T;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface RejectedThenable<T> extends ThenableImpl<T> {
|
|
51
|
-
status: "rejected";
|
|
52
|
-
reason: unknown;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type Thenable<T> = UntrackedThenable<T> | PendingThenable<T> | FulfilledThenable<T> | RejectedThenable<T>;
|
|
56
|
-
|
|
57
|
-
export type Usable<T> = Thenable<T> | Context<T>;
|
|
58
|
-
|
|
59
|
-
export function use<T>(usable: Usable<T>): T;
|
|
60
|
-
|
|
61
|
-
interface ServerContextJSONArray extends ReadonlyArray<ServerContextJSONValue> {}
|
|
62
|
-
export type ServerContextJSONValue =
|
|
63
|
-
| string
|
|
64
|
-
| boolean
|
|
65
|
-
| number
|
|
66
|
-
| null
|
|
67
|
-
| ServerContextJSONArray
|
|
68
|
-
| { [key: string]: ServerContextJSONValue };
|
|
69
|
-
export interface ServerContext<T extends ServerContextJSONValue> {
|
|
70
|
-
Provider: Provider<T>;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Accepts a context object (the value returned from `React.createContext` or `React.createServerContext`) and returns the current
|
|
74
|
-
* context value, as given by the nearest context provider for the given context.
|
|
75
|
-
*
|
|
76
|
-
* @version 16.8.0
|
|
77
|
-
* @see https://react.dev/reference/react/useContext
|
|
78
|
-
*/
|
|
79
|
-
function useContext<T extends ServerContextJSONValue>(context: ServerContext<T>): T;
|
|
80
|
-
export function createServerContext<T extends ServerContextJSONValue>(
|
|
81
|
-
globalName: string,
|
|
82
|
-
defaultValue: T,
|
|
83
|
-
): ServerContext<T>;
|
|
84
|
-
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
86
|
-
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
|
87
|
-
|
|
88
34
|
export function unstable_useCacheRefresh(): () => void;
|
|
89
|
-
|
|
90
|
-
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {
|
|
91
|
-
functions: (formData: FormData) => void;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface TransitionStartFunction {
|
|
95
|
-
/**
|
|
96
|
-
* Marks all state updates inside the async function as transitions
|
|
97
|
-
*
|
|
98
|
-
* @see {https://react.dev/reference/react/useTransition#starttransition}
|
|
99
|
-
*
|
|
100
|
-
* @param callback
|
|
101
|
-
*/
|
|
102
|
-
(callback: () => Promise<VoidOrUndefinedOnly>): void;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Similar to `useTransition` but allows uses where hooks are not available.
|
|
107
|
-
*
|
|
108
|
-
* @param callback An _asynchronous_ function which causes state updates that can be deferred.
|
|
109
|
-
*/
|
|
110
|
-
export function startTransition(scope: () => Promise<VoidOrUndefinedOnly>): void;
|
|
111
|
-
|
|
112
|
-
export function useOptimistic<State>(
|
|
113
|
-
passthrough: State,
|
|
114
|
-
): [State, (action: State | ((pendingState: State) => State)) => void];
|
|
115
|
-
export function useOptimistic<State, Action>(
|
|
116
|
-
passthrough: State,
|
|
117
|
-
reducer: (state: State, action: Action) => State,
|
|
118
|
-
): [State, (action: Action) => void];
|
|
119
|
-
|
|
120
|
-
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
|
|
121
|
-
cleanup: () => VoidOrUndefinedOnly;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function useActionState<State>(
|
|
125
|
-
action: (state: Awaited<State>) => State | Promise<State>,
|
|
126
|
-
initialState: Awaited<State>,
|
|
127
|
-
permalink?: string,
|
|
128
|
-
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
|
129
|
-
export function useActionState<State, Payload>(
|
|
130
|
-
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
|
131
|
-
initialState: Awaited<State>,
|
|
132
|
-
permalink?: string,
|
|
133
|
-
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
134
|
-
|
|
135
|
-
interface DOMAttributes<T> {
|
|
136
|
-
// Transition Events
|
|
137
|
-
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
|
138
|
-
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
|
139
|
-
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
|
140
|
-
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
|
141
|
-
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
|
142
|
-
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @internal Use `Awaited<ReactNode>` instead
|
|
147
|
-
*/
|
|
148
|
-
// Helper type to enable `Awaited<ReactNode>`.
|
|
149
|
-
// Must be a copy of the non-thenables of `ReactNode`.
|
|
150
|
-
type AwaitedReactNode =
|
|
151
|
-
| ReactElement
|
|
152
|
-
| string
|
|
153
|
-
| number
|
|
154
|
-
| Iterable<AwaitedReactNode>
|
|
155
|
-
| ReactPortal
|
|
156
|
-
| boolean
|
|
157
|
-
| null
|
|
158
|
-
| undefined;
|
|
159
|
-
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {
|
|
160
|
-
promises: Promise<AwaitedReactNode>;
|
|
161
|
-
bigints: bigint;
|
|
162
|
-
}
|
|
163
35
|
}
|
react/ts5.0/experimental.d.ts
CHANGED
|
@@ -51,10 +51,13 @@ declare module "." {
|
|
|
51
51
|
unstable_expectedLoadTime?: number | undefined;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export type SuspenseListRevealOrder = "forwards" | "backwards" | "together";
|
|
55
|
-
export type SuspenseListTailMode = "collapsed" | "hidden";
|
|
54
|
+
export type SuspenseListRevealOrder = "forwards" | "backwards" | "together" | "independent";
|
|
55
|
+
export type SuspenseListTailMode = "collapsed" | "hidden" | "visible";
|
|
56
56
|
|
|
57
57
|
export interface SuspenseListCommonProps {
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
|
|
58
61
|
/**
|
|
59
62
|
* Note that SuspenseList require more than one child;
|
|
60
63
|
* it is a runtime warning to provide only a single child.
|
|
@@ -62,33 +65,32 @@ declare module "." {
|
|
|
62
65
|
* It does, however, allow those children to be wrapped inside a single
|
|
63
66
|
* level of `<React.Fragment>`.
|
|
64
67
|
*/
|
|
65
|
-
children: ReactElement |
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
|
|
68
|
+
children: Iterable<ReactElement> | AsyncIterable<ReactElement>;
|
|
69
69
|
/**
|
|
70
70
|
* Defines the order in which the `SuspenseList` children should be revealed.
|
|
71
71
|
*/
|
|
72
|
-
revealOrder: "forwards" | "backwards";
|
|
72
|
+
revealOrder: "forwards" | "backwards" | "unstable_legacy-backwards";
|
|
73
73
|
/**
|
|
74
74
|
* Dictates how unloaded items in a SuspenseList is shown.
|
|
75
75
|
*
|
|
76
76
|
* - By default, `SuspenseList` will show all fallbacks in the list.
|
|
77
77
|
* - `collapsed` shows only the next fallback in the list.
|
|
78
|
-
* - `hidden` doesn
|
|
78
|
+
* - `hidden` doesn't show any unloaded items.
|
|
79
|
+
* - `visible` shows all fallbacks in the list.
|
|
79
80
|
*/
|
|
80
|
-
tail
|
|
81
|
+
tail: SuspenseListTailMode;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
interface NonDirectionalSuspenseListProps extends SuspenseListCommonProps {
|
|
85
|
+
children: ReactNode;
|
|
84
86
|
/**
|
|
85
87
|
* Defines the order in which the `SuspenseList` children should be revealed.
|
|
86
88
|
*/
|
|
87
|
-
revealOrder
|
|
89
|
+
revealOrder: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps["revealOrder"]> | undefined;
|
|
88
90
|
/**
|
|
89
91
|
* The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
|
|
90
92
|
*/
|
|
91
|
-
tail?: never
|
|
93
|
+
tail?: never;
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
export type SuspenseListProps = DirectionalSuspenseListProps | NonDirectionalSuspenseListProps;
|
|
@@ -106,9 +108,6 @@ declare module "." {
|
|
|
106
108
|
*/
|
|
107
109
|
export const unstable_SuspenseList: ExoticComponent<SuspenseListProps>;
|
|
108
110
|
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
110
|
-
export function experimental_useEffectEvent<T extends Function>(event: T): T;
|
|
111
|
-
|
|
112
111
|
type Reference = object;
|
|
113
112
|
type TaintableUniqueValue = string | bigint | ArrayBufferView;
|
|
114
113
|
function experimental_taintUniqueValue(
|
|
@@ -118,10 +117,109 @@ declare module "." {
|
|
|
118
117
|
): void;
|
|
119
118
|
function experimental_taintObjectReference(message: string | undefined, object: Reference): void;
|
|
120
119
|
|
|
121
|
-
export interface
|
|
120
|
+
export interface ViewTransitionInstance {
|
|
121
|
+
/**
|
|
122
|
+
* The {@link ViewTransitionProps name} that was used in the corresponding {@link ViewTransition} component or `"auto"` if the `name` prop was omitted.
|
|
123
|
+
*/
|
|
124
|
+
name: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type ViewTransitionClassPerType = Record<"default" | (string & {}), "none" | "auto" | (string & {})>;
|
|
128
|
+
export type ViewTransitionClass = ViewTransitionClassPerType | ViewTransitionClassPerType[string];
|
|
129
|
+
|
|
130
|
+
export interface ViewTransitionProps {
|
|
131
|
+
children?: ReactNode | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Assigns the {@link https://developer.chrome.com/blog/view-transitions-update-io24#view-transition-class `view-transition-class`} class to the underlying DOM node.
|
|
134
|
+
*/
|
|
135
|
+
default?: ViewTransitionClass | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Combined with {@link className} if this `<ViewTransition>` or its parent Component is mounted and there's no other with the same name being deleted.
|
|
138
|
+
* `"none"` is a special value that deactivates the view transition name under that condition.
|
|
139
|
+
*/
|
|
140
|
+
enter?: ViewTransitionClass | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Combined with {@link className} if this `<ViewTransition>` or its parent Component is unmounted and there's no other with the same name being deleted.
|
|
143
|
+
* `"none"` is a special value that deactivates the view transition name under that condition.
|
|
144
|
+
*/
|
|
145
|
+
exit?: ViewTransitionClass | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* "auto" will automatically assign a view-transition-name to the inner DOM node.
|
|
148
|
+
* That way you can add a View Transition to a Component without controlling its DOM nodes styling otherwise.
|
|
149
|
+
*
|
|
150
|
+
* A difference between this and the browser's built-in view-transition-name: auto is that switching the DOM nodes within the `<ViewTransition>` component preserves the same name so this example cross-fades between the DOM nodes instead of causing an exit and enter.
|
|
151
|
+
* @default "auto"
|
|
152
|
+
*/
|
|
153
|
+
name?: "auto" | (string & {}) | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* The `<ViewTransition>` or its parent Component is mounted and there's no other `<ViewTransition>` with the same name being deleted.
|
|
156
|
+
*/
|
|
157
|
+
onEnter?: (instance: ViewTransitionInstance, types: Array<string>) => void;
|
|
122
158
|
/**
|
|
123
|
-
*
|
|
159
|
+
* The `<ViewTransition>` or its parent Component is unmounted and there's no other `<ViewTransition>` with the same name being deleted.
|
|
124
160
|
*/
|
|
125
|
-
|
|
161
|
+
onExit?: (instance: ViewTransitionInstance, types: Array<string>) => void;
|
|
162
|
+
/**
|
|
163
|
+
* This `<ViewTransition>` is being mounted and another `<ViewTransition>` instance with the same name is being unmounted elsewhere.
|
|
164
|
+
*/
|
|
165
|
+
onShare?: (instance: ViewTransitionInstance, types: Array<string>) => void;
|
|
166
|
+
/**
|
|
167
|
+
* The content of `<ViewTransition>` has changed either due to DOM mutations or because an inner child `<ViewTransition>` has resized.
|
|
168
|
+
*/
|
|
169
|
+
onUpdate?: (instance: ViewTransitionInstance, types: Array<string>) => void;
|
|
170
|
+
ref?: Ref<ViewTransitionInstance> | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Combined with {@link className} if this `<ViewTransition>` is being mounted and another instance with the same name is being unmounted elsewhere.
|
|
173
|
+
* `"none"` is a special value that deactivates the view transition name under that condition.
|
|
174
|
+
*/
|
|
175
|
+
share?: ViewTransitionClass | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* Combined with {@link className} if the content of this `<ViewTransition>` has changed either due to DOM mutations or because an inner child has resized.
|
|
178
|
+
* `"none"` is a special value that deactivates the view transition name under that condition.
|
|
179
|
+
*/
|
|
180
|
+
update?: ViewTransitionClass | undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Opt-in for using {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API View Transitions} in React.
|
|
185
|
+
* View Transitions only trigger for async updates like {@link startTransition}, {@link useDeferredValue}, Actions or <{@link Suspense}> revealing from fallback to content.
|
|
186
|
+
* Synchronous updates provide an opt-out but also guarantee that they commit immediately which View Transitions can't.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://github.com/facebook/react/pull/31975}
|
|
189
|
+
*/
|
|
190
|
+
export const unstable_ViewTransition: ExoticComponent<ViewTransitionProps>;
|
|
191
|
+
|
|
192
|
+
export function unstable_addTransitionType(type: string): void;
|
|
193
|
+
|
|
194
|
+
// @enableGestureTransition
|
|
195
|
+
// Implemented by the specific renderer e.g. `react-dom`.
|
|
196
|
+
// Keep in mind that augmented interfaces merge their JSDoc so if you put
|
|
197
|
+
// JSDoc here and in the renderer, the IDE will display both.
|
|
198
|
+
export interface GestureProvider {}
|
|
199
|
+
export interface GestureOptions {
|
|
200
|
+
rangeStart?: number | undefined;
|
|
201
|
+
rangeEnd?: number | undefined;
|
|
202
|
+
}
|
|
203
|
+
/** */
|
|
204
|
+
export function unstable_startGestureTransition(
|
|
205
|
+
provider: GestureProvider,
|
|
206
|
+
scope: () => void,
|
|
207
|
+
options?: GestureOptions,
|
|
208
|
+
): () => void;
|
|
209
|
+
|
|
210
|
+
// @enableFragmentRefs
|
|
211
|
+
export interface FragmentInstance {}
|
|
212
|
+
|
|
213
|
+
export interface FragmentProps {
|
|
214
|
+
ref?: Ref<FragmentInstance> | undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// @enableSrcObject
|
|
218
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {
|
|
219
|
+
srcObject: Blob;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {
|
|
223
|
+
srcObject: Blob | MediaSource | MediaStream;
|
|
126
224
|
}
|
|
127
225
|
}
|
react/ts5.0/global.d.ts
CHANGED
|
@@ -13,10 +13,12 @@ interface ClipboardEvent extends Event {}
|
|
|
13
13
|
interface CompositionEvent extends Event {}
|
|
14
14
|
interface DragEvent extends Event {}
|
|
15
15
|
interface FocusEvent extends Event {}
|
|
16
|
+
interface InputEvent extends Event {}
|
|
16
17
|
interface KeyboardEvent extends Event {}
|
|
17
18
|
interface MouseEvent extends Event {}
|
|
18
19
|
interface TouchEvent extends Event {}
|
|
19
20
|
interface PointerEvent extends Event {}
|
|
21
|
+
interface ToggleEvent extends Event {}
|
|
20
22
|
interface TransitionEvent extends Event {}
|
|
21
23
|
interface UIEvent extends Event {}
|
|
22
24
|
interface WheelEvent extends Event {}
|
|
@@ -157,3 +159,7 @@ interface WebGLRenderingContext {}
|
|
|
157
159
|
interface WebGL2RenderingContext {}
|
|
158
160
|
|
|
159
161
|
interface TrustedHTML {}
|
|
162
|
+
|
|
163
|
+
interface Blob {}
|
|
164
|
+
interface MediaStream {}
|
|
165
|
+
interface MediaSource {}
|