@types/react 18.3.13 → 19.0.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 +2 -2
- react/canary.d.ts +0 -131
- react/compiler-runtime.d.ts +4 -0
- react/experimental.d.ts +0 -7
- react/index.d.ts +431 -768
- react/package.json +7 -3
- react/ts5.0/canary.d.ts +0 -131
- react/ts5.0/experimental.d.ts +0 -7
- react/ts5.0/index.d.ts +428 -765
- react/ts5.0/v18/global.d.ts +160 -0
- react/ts5.0/v18/index.d.ts +4543 -0
- react/ts5.0/v18/jsx-dev-runtime.d.ts +45 -0
- react/ts5.0/v18/jsx-runtime.d.ts +36 -0
- react/ts5.0/v18/ts5.0/global.d.ts +160 -0
- react/ts5.0/v18/ts5.0/index.d.ts +4530 -0
- react/ts5.0/v18/ts5.0/jsx-dev-runtime.d.ts +44 -0
- react/ts5.0/v18/ts5.0/jsx-runtime.d.ts +35 -0
react/index.d.ts
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
/// <reference path="global.d.ts" />
|
6
6
|
|
7
7
|
import * as CSS from "csstype";
|
8
|
-
import * as PropTypes from "prop-types";
|
9
8
|
|
10
9
|
type NativeAnimationEvent = AnimationEvent;
|
11
10
|
type NativeClipboardEvent = ClipboardEvent;
|
@@ -16,6 +15,7 @@ type NativeKeyboardEvent = KeyboardEvent;
|
|
16
15
|
type NativeMouseEvent = MouseEvent;
|
17
16
|
type NativeTouchEvent = TouchEvent;
|
18
17
|
type NativePointerEvent = PointerEvent;
|
18
|
+
type NativeToggleEvent = ToggleEvent;
|
19
19
|
type NativeTransitionEvent = TransitionEvent;
|
20
20
|
type NativeUIEvent = UIEvent;
|
21
21
|
type NativeWheelEvent = WheelEvent;
|
@@ -33,6 +33,25 @@ type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
|
|
33
33
|
|
34
34
|
declare const UNDEFINED_VOID_ONLY: unique symbol;
|
35
35
|
|
36
|
+
/**
|
37
|
+
* @internal Use `Awaited<ReactNode>` instead
|
38
|
+
*/
|
39
|
+
// Helper type to enable `Awaited<ReactNode>`.
|
40
|
+
// Must be a copy of the non-thenables of `ReactNode`.
|
41
|
+
type AwaitedReactNode =
|
42
|
+
| React.ReactElement
|
43
|
+
| string
|
44
|
+
| number
|
45
|
+
| bigint
|
46
|
+
| Iterable<React.ReactNode>
|
47
|
+
| React.ReactPortal
|
48
|
+
| boolean
|
49
|
+
| null
|
50
|
+
| undefined
|
51
|
+
| React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
52
|
+
keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
53
|
+
];
|
54
|
+
|
36
55
|
/**
|
37
56
|
* The function returned from an effect passed to {@link React.useEffect useEffect},
|
38
57
|
* which can be used to clean up the effect when the component unmounts.
|
@@ -93,8 +112,7 @@ declare namespace React {
|
|
93
112
|
* Represents any user-defined component, either as a function or a class.
|
94
113
|
*
|
95
114
|
* Similar to {@link JSXElementConstructor}, but with extra properties like
|
96
|
-
* {@link FunctionComponent.defaultProps defaultProps }
|
97
|
-
* {@link ComponentClass.contextTypes contextTypes}.
|
115
|
+
* {@link FunctionComponent.defaultProps defaultProps }.
|
98
116
|
*
|
99
117
|
* @template P The props the component accepts.
|
100
118
|
*
|
@@ -107,34 +125,18 @@ declare namespace React {
|
|
107
125
|
* Represents any user-defined component, either as a function or a class.
|
108
126
|
*
|
109
127
|
* Similar to {@link ComponentType}, but without extra properties like
|
110
|
-
* {@link FunctionComponent.defaultProps defaultProps }
|
111
|
-
* {@link ComponentClass.contextTypes contextTypes}.
|
128
|
+
* {@link FunctionComponent.defaultProps defaultProps }.
|
112
129
|
*
|
113
130
|
* @template P The props the component accepts.
|
114
131
|
*/
|
115
132
|
type JSXElementConstructor<P> =
|
116
133
|
| ((
|
117
134
|
props: P,
|
118
|
-
/**
|
119
|
-
* @deprecated
|
120
|
-
*
|
121
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components React Docs}
|
122
|
-
*/
|
123
|
-
deprecatedLegacyContext?: any,
|
124
135
|
) => ReactNode)
|
125
|
-
|
126
|
-
|
127
|
-
/**
|
128
|
-
* @deprecated
|
129
|
-
*
|
130
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
131
|
-
*/
|
132
|
-
deprecatedLegacyContext?: any,
|
133
|
-
) => Component<any, any>);
|
136
|
+
// constructor signature must match React.Component
|
137
|
+
| (new(props: P) => Component<any, any>);
|
134
138
|
|
135
139
|
/**
|
136
|
-
* A readonly ref container where {@link current} cannot be mutated.
|
137
|
-
*
|
138
140
|
* Created by {@link createRef}, or {@link useRef} when passed `null`.
|
139
141
|
*
|
140
142
|
* @template T The type of the ref's value.
|
@@ -151,7 +153,7 @@ declare namespace React {
|
|
151
153
|
/**
|
152
154
|
* The current value of the ref.
|
153
155
|
*/
|
154
|
-
|
156
|
+
current: T;
|
155
157
|
}
|
156
158
|
|
157
159
|
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
|
@@ -174,6 +176,7 @@ declare namespace React {
|
|
174
176
|
instance: T | null,
|
175
177
|
):
|
176
178
|
| void
|
179
|
+
| (() => VoidOrUndefinedOnly)
|
177
180
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[
|
178
181
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES
|
179
182
|
];
|
@@ -186,22 +189,15 @@ declare namespace React {
|
|
186
189
|
* @see {@link RefObject}
|
187
190
|
*/
|
188
191
|
|
189
|
-
type Ref<T> = RefCallback<T> | RefObject<T> | null;
|
192
|
+
type Ref<T> = RefCallback<T> | RefObject<T | null> | null;
|
190
193
|
/**
|
191
|
-
*
|
192
|
-
*
|
193
|
-
* @see {@link https://react.dev/reference/react/Component#refs React Docs}
|
194
|
-
*
|
195
|
-
* @example
|
196
|
-
*
|
197
|
-
* ```tsx
|
198
|
-
* <div ref="myRef" />
|
199
|
-
* ```
|
194
|
+
* @deprecated Use `Ref` instead. String refs are no longer supported.
|
195
|
+
* If you're typing a library with support for React versions with string refs, use `RefAttributes<T>['ref']` instead.
|
200
196
|
*/
|
201
|
-
|
202
|
-
type LegacyRef<T> = string | Ref<T>;
|
203
|
-
|
197
|
+
type LegacyRef<T> = Ref<T>;
|
204
198
|
/**
|
199
|
+
* @deprecated Use `ComponentRef<T>` instead
|
200
|
+
*
|
205
201
|
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
206
202
|
*
|
207
203
|
* @template C The component type.
|
@@ -222,17 +218,9 @@ declare namespace React {
|
|
222
218
|
C extends
|
223
219
|
| ForwardRefExoticComponent<any>
|
224
220
|
| { new(props: any): Component<any> }
|
225
|
-
| ((props: any
|
221
|
+
| ((props: any) => ReactNode)
|
226
222
|
| keyof JSX.IntrinsicElements,
|
227
|
-
> =
|
228
|
-
// need to check first if `ref` is a valid prop for ts@3.0
|
229
|
-
// otherwise it will infer `{}` instead of `never`
|
230
|
-
"ref" extends keyof ComponentPropsWithRef<C>
|
231
|
-
? NonNullable<ComponentPropsWithRef<C>["ref"]> extends RefAttributes<
|
232
|
-
infer Instance
|
233
|
-
>["ref"] ? Instance
|
234
|
-
: never
|
235
|
-
: never;
|
223
|
+
> = ComponentRef<C>;
|
236
224
|
|
237
225
|
type ComponentState = any;
|
238
226
|
|
@@ -300,7 +288,7 @@ declare namespace React {
|
|
300
288
|
*
|
301
289
|
* @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
|
302
290
|
*/
|
303
|
-
ref?:
|
291
|
+
ref?: Ref<T> | undefined;
|
304
292
|
}
|
305
293
|
|
306
294
|
/**
|
@@ -325,7 +313,7 @@ declare namespace React {
|
|
325
313
|
* ```
|
326
314
|
*/
|
327
315
|
interface ReactElement<
|
328
|
-
P =
|
316
|
+
P = unknown,
|
329
317
|
T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
|
330
318
|
> {
|
331
319
|
type: T;
|
@@ -341,13 +329,28 @@ declare namespace React {
|
|
341
329
|
P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
|
342
330
|
> extends ReactElement<P, Exclude<T, number>> {}
|
343
331
|
|
332
|
+
/**
|
333
|
+
* @deprecated Use `ReactElement<P, React.FunctionComponent<P>>`
|
334
|
+
*/
|
344
335
|
interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
|
336
|
+
/**
|
337
|
+
* @deprecated Use `element.props.ref` instead.
|
338
|
+
*/
|
345
339
|
ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
|
346
340
|
}
|
347
341
|
|
342
|
+
/**
|
343
|
+
* @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
|
344
|
+
*/
|
348
345
|
type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
|
346
|
+
/**
|
347
|
+
* @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
|
348
|
+
*/
|
349
349
|
interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
|
350
|
-
|
350
|
+
/**
|
351
|
+
* @deprecated Use `element.props.ref` instead.
|
352
|
+
*/
|
353
|
+
ref?: Ref<T> | undefined;
|
351
354
|
}
|
352
355
|
|
353
356
|
/**
|
@@ -356,89 +359,34 @@ declare namespace React {
|
|
356
359
|
type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
|
357
360
|
|
358
361
|
// string fallback for custom web-components
|
362
|
+
/**
|
363
|
+
* @deprecated Use `ReactElement<P, string>`
|
364
|
+
*/
|
359
365
|
interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
|
360
366
|
extends ReactElement<P, string>
|
361
367
|
{
|
362
|
-
|
368
|
+
/**
|
369
|
+
* @deprecated Use `element.props.ref` instead.
|
370
|
+
*/
|
371
|
+
ref: Ref<T>;
|
363
372
|
}
|
364
373
|
|
365
374
|
// ReactHTML for ReactHTMLElement
|
366
375
|
interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
|
367
376
|
|
368
377
|
interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
|
369
|
-
type:
|
378
|
+
type: HTMLElementType;
|
370
379
|
}
|
371
380
|
|
372
381
|
// ReactSVG for ReactSVGElement
|
373
382
|
interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
|
374
|
-
type:
|
383
|
+
type: SVGElementType;
|
375
384
|
}
|
376
385
|
|
377
386
|
interface ReactPortal extends ReactElement {
|
378
387
|
children: ReactNode;
|
379
388
|
}
|
380
389
|
|
381
|
-
//
|
382
|
-
// Factories
|
383
|
-
// ----------------------------------------------------------------------
|
384
|
-
|
385
|
-
type Factory<P> = (props?: Attributes & P, ...children: ReactNode[]) => ReactElement<P>;
|
386
|
-
|
387
|
-
/**
|
388
|
-
* @deprecated Please use `FunctionComponentFactory`
|
389
|
-
*/
|
390
|
-
type SFCFactory<P> = FunctionComponentFactory<P>;
|
391
|
-
|
392
|
-
type FunctionComponentFactory<P> = (
|
393
|
-
props?: Attributes & P,
|
394
|
-
...children: ReactNode[]
|
395
|
-
) => FunctionComponentElement<P>;
|
396
|
-
|
397
|
-
type ComponentFactory<P, T extends Component<P, ComponentState>> = (
|
398
|
-
props?: ClassAttributes<T> & P,
|
399
|
-
...children: ReactNode[]
|
400
|
-
) => CElement<P, T>;
|
401
|
-
|
402
|
-
type CFactory<P, T extends Component<P, ComponentState>> = ComponentFactory<P, T>;
|
403
|
-
type ClassicFactory<P> = CFactory<P, ClassicComponent<P, ComponentState>>;
|
404
|
-
|
405
|
-
type DOMFactory<P extends DOMAttributes<T>, T extends Element> = (
|
406
|
-
props?: ClassAttributes<T> & P | null,
|
407
|
-
...children: ReactNode[]
|
408
|
-
) => DOMElement<P, T>;
|
409
|
-
|
410
|
-
interface HTMLFactory<T extends HTMLElement> extends DetailedHTMLFactory<AllHTMLAttributes<T>, T> {}
|
411
|
-
|
412
|
-
interface DetailedHTMLFactory<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMFactory<P, T> {
|
413
|
-
(props?: ClassAttributes<T> & P | null, ...children: ReactNode[]): DetailedReactHTMLElement<P, T>;
|
414
|
-
}
|
415
|
-
|
416
|
-
interface SVGFactory extends DOMFactory<SVGAttributes<SVGElement>, SVGElement> {
|
417
|
-
(
|
418
|
-
props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null,
|
419
|
-
...children: ReactNode[]
|
420
|
-
): ReactSVGElement;
|
421
|
-
}
|
422
|
-
|
423
|
-
/**
|
424
|
-
* @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
|
425
|
-
*/
|
426
|
-
type ReactText = string | number;
|
427
|
-
/**
|
428
|
-
* @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
|
429
|
-
*/
|
430
|
-
type ReactChild = ReactElement | string | number;
|
431
|
-
|
432
|
-
/**
|
433
|
-
* @deprecated Use either `ReactNode[]` if you need an array or `Iterable<ReactNode>` if its passed to a host component.
|
434
|
-
*/
|
435
|
-
interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
|
436
|
-
/**
|
437
|
-
* WARNING: Not related to `React.Fragment`.
|
438
|
-
* @deprecated This type is not relevant when using React. Inline the type instead to make the intent clear.
|
439
|
-
*/
|
440
|
-
type ReactFragment = Iterable<ReactNode>;
|
441
|
-
|
442
390
|
/**
|
443
391
|
* Different release channels declare additional types of ReactNode this particular release channel accepts.
|
444
392
|
* App or library types should never augment this interface.
|
@@ -479,6 +427,7 @@ declare namespace React {
|
|
479
427
|
| ReactElement
|
480
428
|
| string
|
481
429
|
| number
|
430
|
+
| bigint
|
482
431
|
| Iterable<ReactNode>
|
483
432
|
| ReactPortal
|
484
433
|
| boolean
|
@@ -486,36 +435,13 @@ declare namespace React {
|
|
486
435
|
| undefined
|
487
436
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
488
437
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
489
|
-
]
|
438
|
+
]
|
439
|
+
| Promise<AwaitedReactNode>;
|
490
440
|
|
491
441
|
//
|
492
442
|
// Top Level API
|
493
443
|
// ----------------------------------------------------------------------
|
494
444
|
|
495
|
-
// DOM Elements
|
496
|
-
/** @deprecated */
|
497
|
-
function createFactory<T extends HTMLElement>(
|
498
|
-
type: keyof ReactHTML,
|
499
|
-
): HTMLFactory<T>;
|
500
|
-
/** @deprecated */
|
501
|
-
function createFactory(
|
502
|
-
type: keyof ReactSVG,
|
503
|
-
): SVGFactory;
|
504
|
-
/** @deprecated */
|
505
|
-
function createFactory<P extends DOMAttributes<T>, T extends Element>(
|
506
|
-
type: string,
|
507
|
-
): DOMFactory<P, T>;
|
508
|
-
|
509
|
-
// Custom components
|
510
|
-
/** @deprecated */
|
511
|
-
function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
|
512
|
-
/** @deprecated */
|
513
|
-
function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
514
|
-
type: ClassType<P, T, C>,
|
515
|
-
): CFactory<P, T>;
|
516
|
-
/** @deprecated */
|
517
|
-
function createFactory<P>(type: ComponentClass<P>): Factory<P>;
|
518
|
-
|
519
445
|
// DOM Elements
|
520
446
|
// TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
|
521
447
|
function createElement(
|
@@ -524,12 +450,12 @@ declare namespace React {
|
|
524
450
|
...children: ReactNode[]
|
525
451
|
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
526
452
|
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
527
|
-
type:
|
453
|
+
type: HTMLElementType,
|
528
454
|
props?: ClassAttributes<T> & P | null,
|
529
455
|
...children: ReactNode[]
|
530
456
|
): DetailedReactHTMLElement<P, T>;
|
531
457
|
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
532
|
-
type:
|
458
|
+
type: SVGElementType,
|
533
459
|
props?: ClassAttributes<T> & P | null,
|
534
460
|
...children: ReactNode[]
|
535
461
|
): ReactSVGElement;
|
@@ -658,7 +584,6 @@ declare namespace React {
|
|
658
584
|
* @template P The props the component accepts.
|
659
585
|
*/
|
660
586
|
interface ProviderExoticComponent<P> extends ExoticComponent<P> {
|
661
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
662
587
|
}
|
663
588
|
|
664
589
|
/**
|
@@ -740,7 +665,7 @@ declare namespace React {
|
|
740
665
|
* const ThemeContext = createContext('light');
|
741
666
|
* ```
|
742
667
|
*/
|
743
|
-
interface Context<T> {
|
668
|
+
interface Context<T> extends Provider<T> {
|
744
669
|
Provider: Provider<T>;
|
745
670
|
Consumer: Consumer<T>;
|
746
671
|
/**
|
@@ -769,6 +694,13 @@ declare namespace React {
|
|
769
694
|
* import { createContext } from 'react';
|
770
695
|
*
|
771
696
|
* const ThemeContext = createContext('light');
|
697
|
+
* function App() {
|
698
|
+
* return (
|
699
|
+
* <ThemeContext value="dark">
|
700
|
+
* <Toolbar />
|
701
|
+
* </ThemeContext>
|
702
|
+
* );
|
703
|
+
* }
|
772
704
|
* ```
|
773
705
|
*/
|
774
706
|
function createContext<T>(
|
@@ -779,9 +711,6 @@ declare namespace React {
|
|
779
711
|
|
780
712
|
function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
|
781
713
|
|
782
|
-
/**
|
783
|
-
* Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
|
784
|
-
*/
|
785
714
|
const Children: {
|
786
715
|
map<T, C>(
|
787
716
|
children: C | readonly C[],
|
@@ -987,6 +916,12 @@ declare namespace React {
|
|
987
916
|
*/
|
988
917
|
static contextType?: Context<any> | undefined;
|
989
918
|
|
919
|
+
/**
|
920
|
+
* Ignored by React.
|
921
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
922
|
+
*/
|
923
|
+
static propTypes?: any;
|
924
|
+
|
990
925
|
/**
|
991
926
|
* If using the new style context, re-declare this in your class to be the
|
992
927
|
* `React.ContextType` of your `static contextType`.
|
@@ -1005,12 +940,8 @@ declare namespace React {
|
|
1005
940
|
*/
|
1006
941
|
context: unknown;
|
1007
942
|
|
943
|
+
// Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
|
1008
944
|
constructor(props: P);
|
1009
|
-
/**
|
1010
|
-
* @deprecated
|
1011
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}
|
1012
|
-
*/
|
1013
|
-
constructor(props: P, context: any);
|
1014
945
|
|
1015
946
|
// We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
|
1016
947
|
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
|
@@ -1025,14 +956,6 @@ declare namespace React {
|
|
1025
956
|
|
1026
957
|
readonly props: Readonly<P>;
|
1027
958
|
state: Readonly<S>;
|
1028
|
-
/**
|
1029
|
-
* @deprecated
|
1030
|
-
*
|
1031
|
-
* @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
|
1032
|
-
*/
|
1033
|
-
refs: {
|
1034
|
-
[key: string]: ReactInstance;
|
1035
|
-
};
|
1036
959
|
}
|
1037
960
|
|
1038
961
|
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
|
@@ -1049,10 +972,6 @@ declare namespace React {
|
|
1049
972
|
getInitialState?(): S;
|
1050
973
|
}
|
1051
974
|
|
1052
|
-
interface ChildContextProvider<CC> {
|
1053
|
-
getChildContext(): CC;
|
1054
|
-
}
|
1055
|
-
|
1056
975
|
//
|
1057
976
|
// Class Interfaces
|
1058
977
|
// ----------------------------------------------------------------------
|
@@ -1117,58 +1036,12 @@ declare namespace React {
|
|
1117
1036
|
* ```
|
1118
1037
|
*/
|
1119
1038
|
interface FunctionComponent<P = {}> {
|
1120
|
-
(
|
1121
|
-
props: P,
|
1122
|
-
/**
|
1123
|
-
* @deprecated
|
1124
|
-
*
|
1125
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
1126
|
-
*/
|
1127
|
-
deprecatedLegacyContext?: any,
|
1128
|
-
): ReactNode;
|
1129
|
-
/**
|
1130
|
-
* Used to declare the types of the props accepted by the
|
1131
|
-
* component. These types will be checked during rendering
|
1132
|
-
* and in development only.
|
1133
|
-
*
|
1134
|
-
* We recommend using TypeScript instead of checking prop
|
1135
|
-
* types at runtime.
|
1136
|
-
*
|
1137
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
1138
|
-
*/
|
1139
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
1039
|
+
(props: P): ReactNode;
|
1140
1040
|
/**
|
1141
|
-
*
|
1142
|
-
*
|
1143
|
-
* Lets you specify which legacy context is consumed by
|
1144
|
-
* this component.
|
1145
|
-
*
|
1146
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
1041
|
+
* Ignored by React.
|
1042
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1147
1043
|
*/
|
1148
|
-
|
1149
|
-
/**
|
1150
|
-
* Used to define default values for the props accepted by
|
1151
|
-
* the component.
|
1152
|
-
*
|
1153
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
1154
|
-
*
|
1155
|
-
* @example
|
1156
|
-
*
|
1157
|
-
* ```tsx
|
1158
|
-
* type Props = { name?: string }
|
1159
|
-
*
|
1160
|
-
* const MyComponent: FC<Props> = (props) => {
|
1161
|
-
* return <div>{props.name}</div>
|
1162
|
-
* }
|
1163
|
-
*
|
1164
|
-
* MyComponent.defaultProps = {
|
1165
|
-
* name: 'John Doe'
|
1166
|
-
* }
|
1167
|
-
* ```
|
1168
|
-
*
|
1169
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
1170
|
-
*/
|
1171
|
-
defaultProps?: Partial<P> | undefined;
|
1044
|
+
propTypes?: any;
|
1172
1045
|
/**
|
1173
1046
|
* Used in debugging messages. You might want to set it
|
1174
1047
|
* explicitly if you want to display a different name for
|
@@ -1190,44 +1063,14 @@ declare namespace React {
|
|
1190
1063
|
displayName?: string | undefined;
|
1191
1064
|
}
|
1192
1065
|
|
1193
|
-
/**
|
1194
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
1195
|
-
*
|
1196
|
-
* @see {@link React.FunctionComponent}
|
1197
|
-
* @alias {@link VoidFunctionComponent}
|
1198
|
-
*/
|
1199
|
-
type VFC<P = {}> = VoidFunctionComponent<P>;
|
1200
|
-
|
1201
|
-
/**
|
1202
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
1203
|
-
*
|
1204
|
-
* @see {@link React.FunctionComponent}
|
1205
|
-
*/
|
1206
|
-
interface VoidFunctionComponent<P = {}> {
|
1207
|
-
(
|
1208
|
-
props: P,
|
1209
|
-
/**
|
1210
|
-
* @deprecated
|
1211
|
-
*
|
1212
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
1213
|
-
*/
|
1214
|
-
deprecatedLegacyContext?: any,
|
1215
|
-
): ReactNode;
|
1216
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
1217
|
-
contextTypes?: ValidationMap<any> | undefined;
|
1218
|
-
/**
|
1219
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
1220
|
-
*/
|
1221
|
-
defaultProps?: Partial<P> | undefined;
|
1222
|
-
displayName?: string | undefined;
|
1223
|
-
}
|
1224
|
-
|
1225
1066
|
/**
|
1226
1067
|
* The type of the ref received by a {@link ForwardRefRenderFunction}.
|
1227
1068
|
*
|
1228
1069
|
* @see {@link ForwardRefRenderFunction}
|
1229
1070
|
*/
|
1230
|
-
|
1071
|
+
// Making T nullable is assuming the refs will be managed by React or the component impl will write it somewhere else.
|
1072
|
+
// But this isn't necessarily true. We haven't heard complains about it yet and hopefully `forwardRef` is removed from React before we do.
|
1073
|
+
type ForwardedRef<T> = ((instance: T | null) => void) | RefObject<T | null> | null;
|
1231
1074
|
|
1232
1075
|
/**
|
1233
1076
|
* The type of the function passed to {@link forwardRef}. This is considered different
|
@@ -1256,19 +1099,10 @@ declare namespace React {
|
|
1256
1099
|
*/
|
1257
1100
|
displayName?: string | undefined;
|
1258
1101
|
/**
|
1259
|
-
*
|
1260
|
-
*
|
1261
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
1262
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
1102
|
+
* Ignored by React.
|
1103
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1263
1104
|
*/
|
1264
|
-
|
1265
|
-
/**
|
1266
|
-
* propTypes are not supported on render functions passed to forwardRef.
|
1267
|
-
*
|
1268
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
1269
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
1270
|
-
*/
|
1271
|
-
propTypes?: never | undefined;
|
1105
|
+
propTypes?: any;
|
1272
1106
|
}
|
1273
1107
|
|
1274
1108
|
/**
|
@@ -1278,48 +1112,14 @@ declare namespace React {
|
|
1278
1112
|
* @template S The internal state of the component.
|
1279
1113
|
*/
|
1280
1114
|
interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
|
1281
|
-
|
1282
|
-
|
1283
|
-
/**
|
1284
|
-
* @deprecated
|
1285
|
-
*
|
1286
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
1287
|
-
*/
|
1288
|
-
deprecatedLegacyContext?: any,
|
1289
|
-
): Component<P, S>;
|
1115
|
+
// constructor signature must match React.Component
|
1116
|
+
new(props: P): Component<P, S>;
|
1290
1117
|
/**
|
1291
|
-
*
|
1292
|
-
*
|
1293
|
-
* and in development only.
|
1294
|
-
*
|
1295
|
-
* We recommend using TypeScript instead of checking prop
|
1296
|
-
* types at runtime.
|
1297
|
-
*
|
1298
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
1118
|
+
* Ignored by React.
|
1119
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1299
1120
|
*/
|
1300
|
-
propTypes?:
|
1121
|
+
propTypes?: any;
|
1301
1122
|
contextType?: Context<any> | undefined;
|
1302
|
-
/**
|
1303
|
-
* @deprecated use {@link ComponentClass.contextType} instead
|
1304
|
-
*
|
1305
|
-
* Lets you specify which legacy context is consumed by
|
1306
|
-
* this component.
|
1307
|
-
*
|
1308
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
1309
|
-
*/
|
1310
|
-
contextTypes?: ValidationMap<any> | undefined;
|
1311
|
-
/**
|
1312
|
-
* @deprecated
|
1313
|
-
*
|
1314
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
|
1315
|
-
*/
|
1316
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
1317
|
-
/**
|
1318
|
-
* Used to define default values for the props accepted by
|
1319
|
-
* the component.
|
1320
|
-
*
|
1321
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
1322
|
-
*/
|
1323
1123
|
defaultProps?: Partial<P> | undefined;
|
1324
1124
|
/**
|
1325
1125
|
* Used in debugging messages. You might want to set it
|
@@ -1338,7 +1138,7 @@ declare namespace React {
|
|
1338
1138
|
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
1339
1139
|
*/
|
1340
1140
|
interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
|
1341
|
-
new(props: P
|
1141
|
+
new(props: P): ClassicComponent<P, ComponentState>;
|
1342
1142
|
getDefaultProps?(): P;
|
1343
1143
|
}
|
1344
1144
|
|
@@ -1353,7 +1153,7 @@ declare namespace React {
|
|
1353
1153
|
*/
|
1354
1154
|
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
1355
1155
|
& C
|
1356
|
-
& (new(props: P
|
1156
|
+
& (new(props: P) => T);
|
1357
1157
|
|
1358
1158
|
//
|
1359
1159
|
// Component Specs and Lifecycle
|
@@ -1377,7 +1177,7 @@ declare namespace React {
|
|
1377
1177
|
* If false is returned, {@link Component.render}, `componentWillUpdate`
|
1378
1178
|
* and `componentDidUpdate` will not be called.
|
1379
1179
|
*/
|
1380
|
-
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S
|
1180
|
+
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): boolean;
|
1381
1181
|
/**
|
1382
1182
|
* Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
|
1383
1183
|
* cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
|
@@ -1476,7 +1276,7 @@ declare namespace React {
|
|
1476
1276
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
|
1477
1277
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1478
1278
|
*/
|
1479
|
-
componentWillReceiveProps?(nextProps: Readonly<P
|
1279
|
+
componentWillReceiveProps?(nextProps: Readonly<P>): void;
|
1480
1280
|
/**
|
1481
1281
|
* Called when the component may be receiving new props.
|
1482
1282
|
* React may call this even if props have not changed, so be sure to compare new and existing
|
@@ -1494,7 +1294,7 @@ declare namespace React {
|
|
1494
1294
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
|
1495
1295
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1496
1296
|
*/
|
1497
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P
|
1297
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>): void;
|
1498
1298
|
/**
|
1499
1299
|
* Called immediately before rendering when new props or state is received. Not called for the initial render.
|
1500
1300
|
*
|
@@ -1508,7 +1308,7 @@ declare namespace React {
|
|
1508
1308
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
|
1509
1309
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1510
1310
|
*/
|
1511
|
-
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S
|
1311
|
+
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
|
1512
1312
|
/**
|
1513
1313
|
* Called immediately before rendering when new props or state is received. Not called for the initial render.
|
1514
1314
|
*
|
@@ -1524,41 +1324,10 @@ declare namespace React {
|
|
1524
1324
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
|
1525
1325
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1526
1326
|
*/
|
1527
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S
|
1327
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
|
1528
1328
|
}
|
1529
1329
|
|
1530
|
-
|
1531
|
-
* @deprecated
|
1532
|
-
*
|
1533
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
1534
|
-
*/
|
1535
|
-
interface Mixin<P, S> extends ComponentLifecycle<P, S> {
|
1536
|
-
mixins?: Array<Mixin<P, S>> | undefined;
|
1537
|
-
statics?: {
|
1538
|
-
[key: string]: any;
|
1539
|
-
} | undefined;
|
1540
|
-
|
1541
|
-
displayName?: string | undefined;
|
1542
|
-
propTypes?: ValidationMap<any> | undefined;
|
1543
|
-
contextTypes?: ValidationMap<any> | undefined;
|
1544
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
1545
|
-
|
1546
|
-
getDefaultProps?(): P;
|
1547
|
-
getInitialState?(): S;
|
1548
|
-
}
|
1549
|
-
|
1550
|
-
/**
|
1551
|
-
* @deprecated
|
1552
|
-
*
|
1553
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
1554
|
-
*/
|
1555
|
-
interface ComponentSpec<P, S> extends Mixin<P, S> {
|
1556
|
-
render(): ReactNode;
|
1557
|
-
|
1558
|
-
[propertyName: string]: any;
|
1559
|
-
}
|
1560
|
-
|
1561
|
-
function createRef<T>(): RefObject<T>;
|
1330
|
+
function createRef<T>(): RefObject<T | null>;
|
1562
1331
|
|
1563
1332
|
/**
|
1564
1333
|
* The type of the component returned from {@link forwardRef}.
|
@@ -1569,10 +1338,10 @@ declare namespace React {
|
|
1569
1338
|
*/
|
1570
1339
|
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
1571
1340
|
/**
|
1572
|
-
*
|
1341
|
+
* Ignored by React.
|
1342
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1573
1343
|
*/
|
1574
|
-
|
1575
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
1344
|
+
propTypes?: any;
|
1576
1345
|
}
|
1577
1346
|
|
1578
1347
|
/**
|
@@ -1609,23 +1378,18 @@ declare namespace React {
|
|
1609
1378
|
/**
|
1610
1379
|
* Omits the 'ref' attribute from the given props object.
|
1611
1380
|
*
|
1612
|
-
* @template
|
1381
|
+
* @template Props The props object type.
|
1613
1382
|
*/
|
1614
|
-
type PropsWithoutRef<
|
1383
|
+
type PropsWithoutRef<Props> =
|
1615
1384
|
// Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
|
1616
1385
|
// see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
1617
1386
|
// https://github.com/Microsoft/TypeScript/issues/28339
|
1618
|
-
|
1619
|
-
/**
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
? P extends { ref?: infer R | undefined }
|
1625
|
-
? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
1626
|
-
: P
|
1627
|
-
: P
|
1628
|
-
: P;
|
1387
|
+
Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
|
1388
|
+
/**
|
1389
|
+
* Ensures that the props do not include string ref, which cannot be forwarded
|
1390
|
+
* @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
|
1391
|
+
*/
|
1392
|
+
type PropsWithRef<Props> = Props;
|
1629
1393
|
|
1630
1394
|
type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
|
1631
1395
|
|
@@ -1657,7 +1421,7 @@ declare namespace React {
|
|
1657
1421
|
* ```
|
1658
1422
|
*/
|
1659
1423
|
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
1660
|
-
JSXElementConstructor<infer
|
1424
|
+
JSXElementConstructor<infer Props> ? Props
|
1661
1425
|
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
1662
1426
|
: {};
|
1663
1427
|
|
@@ -1684,9 +1448,11 @@ declare namespace React {
|
|
1684
1448
|
* type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
|
1685
1449
|
* ```
|
1686
1450
|
*/
|
1687
|
-
type ComponentPropsWithRef<T extends ElementType> = T extends
|
1688
|
-
|
1689
|
-
:
|
1451
|
+
type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
|
1452
|
+
// If it's a class i.e. newable we're dealing with a class component
|
1453
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
1454
|
+
: Props
|
1455
|
+
: ComponentProps<T>;
|
1690
1456
|
/**
|
1691
1457
|
* Used to retrieve the props a custom component accepts with its ref.
|
1692
1458
|
*
|
@@ -1703,9 +1469,10 @@ declare namespace React {
|
|
1703
1469
|
* type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
|
1704
1470
|
* ```
|
1705
1471
|
*/
|
1706
|
-
type CustomComponentPropsWithRef<T extends ComponentType> = T extends
|
1707
|
-
|
1708
|
-
|
1472
|
+
type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
|
1473
|
+
// If it's a class i.e. newable we're dealing with a class component
|
1474
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
1475
|
+
: Props
|
1709
1476
|
: never;
|
1710
1477
|
|
1711
1478
|
/**
|
@@ -1733,10 +1500,24 @@ declare namespace React {
|
|
1733
1500
|
*/
|
1734
1501
|
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
1735
1502
|
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1503
|
+
/**
|
1504
|
+
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
1505
|
+
*
|
1506
|
+
* @template C The component type.
|
1507
|
+
*
|
1508
|
+
* @example
|
1509
|
+
*
|
1510
|
+
* ```tsx
|
1511
|
+
* type MyComponentRef = React.ElementRef<typeof MyComponent>;
|
1512
|
+
* ```
|
1513
|
+
*
|
1514
|
+
* @example
|
1515
|
+
*
|
1516
|
+
* ```tsx
|
1517
|
+
* type DivRef = React.ElementRef<'div'>;
|
1518
|
+
* ```
|
1519
|
+
*/
|
1520
|
+
type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
1740
1521
|
: never;
|
1741
1522
|
|
1742
1523
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
@@ -1837,6 +1618,11 @@ declare namespace React {
|
|
1837
1618
|
* A {@link Dispatch} function can sometimes be called without any arguments.
|
1838
1619
|
*/
|
1839
1620
|
type DispatchWithoutAction = () => void;
|
1621
|
+
// Limit the reducer to accept only 0 or 1 action arguments
|
1622
|
+
// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
|
1623
|
+
type AnyActionArg = [] | [any];
|
1624
|
+
// Get the dispatch type from the reducer arguments (captures optional action argument correctly)
|
1625
|
+
type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
|
1840
1626
|
// Unlike redux, the actions _can_ be anything
|
1841
1627
|
type Reducer<S, A> = (prevState: S, action: A) => S;
|
1842
1628
|
// If useReducer accepts a reducer without action, dispatch may be called without any parameters.
|
@@ -1844,15 +1630,14 @@ declare namespace React {
|
|
1844
1630
|
// types used to try and prevent the compiler from reducing S
|
1845
1631
|
// to a supertype common with the second argument to useReducer()
|
1846
1632
|
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
1847
|
-
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
1848
|
-
// The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
|
1849
|
-
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
|
1850
|
-
: never;
|
1851
1633
|
type DependencyList = readonly unknown[];
|
1852
1634
|
|
1853
1635
|
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
1854
1636
|
type EffectCallback = () => void | Destructor;
|
1855
1637
|
|
1638
|
+
/**
|
1639
|
+
* @deprecated Use `RefObject` instead.
|
1640
|
+
*/
|
1856
1641
|
interface MutableRefObject<T> {
|
1857
1642
|
current: T;
|
1858
1643
|
}
|
@@ -1891,46 +1676,10 @@ declare namespace React {
|
|
1891
1676
|
* @version 16.8.0
|
1892
1677
|
* @see {@link https://react.dev/reference/react/useReducer}
|
1893
1678
|
*/
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
initializer: (arg: I) => ReducerStateWithoutAction<R>,
|
1899
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
1900
|
-
/**
|
1901
|
-
* An alternative to `useState`.
|
1902
|
-
*
|
1903
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1904
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1905
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
1906
|
-
*
|
1907
|
-
* @version 16.8.0
|
1908
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
1909
|
-
*/
|
1910
|
-
// overload where dispatch could accept 0 arguments.
|
1911
|
-
function useReducer<R extends ReducerWithoutAction<any>>(
|
1912
|
-
reducer: R,
|
1913
|
-
initializerArg: ReducerStateWithoutAction<R>,
|
1914
|
-
initializer?: undefined,
|
1915
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
1916
|
-
/**
|
1917
|
-
* An alternative to `useState`.
|
1918
|
-
*
|
1919
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1920
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1921
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
1922
|
-
*
|
1923
|
-
* @version 16.8.0
|
1924
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
1925
|
-
*/
|
1926
|
-
// overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
|
1927
|
-
// If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
|
1928
|
-
// the last overload effectively behaves as if the identity function (x => x) is the initializer.
|
1929
|
-
function useReducer<R extends Reducer<any, any>, I>(
|
1930
|
-
reducer: R,
|
1931
|
-
initializerArg: I & ReducerState<R>,
|
1932
|
-
initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
|
1933
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1679
|
+
function useReducer<S, A extends AnyActionArg>(
|
1680
|
+
reducer: (prevState: S, ...args: A) => S,
|
1681
|
+
initialState: S,
|
1682
|
+
): [S, ActionDispatch<A>];
|
1934
1683
|
/**
|
1935
1684
|
* An alternative to `useState`.
|
1936
1685
|
*
|
@@ -1941,12 +1690,10 @@ declare namespace React {
|
|
1941
1690
|
* @version 16.8.0
|
1942
1691
|
* @see {@link https://react.dev/reference/react/useReducer}
|
1943
1692
|
*/
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
initializer: (arg: I) => ReducerState<R>,
|
1949
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1693
|
+
function useReducer<S, A extends AnyActionArg>(
|
1694
|
+
reducer: (prevState: S, ...args: A) => S,
|
1695
|
+
initialState: S,
|
1696
|
+
): [S, ActionDispatch<A>];
|
1950
1697
|
/**
|
1951
1698
|
* An alternative to `useState`.
|
1952
1699
|
*
|
@@ -1957,21 +1704,11 @@ declare namespace React {
|
|
1957
1704
|
* @version 16.8.0
|
1958
1705
|
* @see {@link https://react.dev/reference/react/useReducer}
|
1959
1706
|
*/
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
// supertype between the reducer's return type and the initialState (or the initializer's return type),
|
1966
|
-
// which would prevent autocompletion from ever working.
|
1967
|
-
|
1968
|
-
// TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
|
1969
|
-
// in older versions, or a regression in newer versions of the typescript completion service.
|
1970
|
-
function useReducer<R extends Reducer<any, any>>(
|
1971
|
-
reducer: R,
|
1972
|
-
initialState: ReducerState<R>,
|
1973
|
-
initializer?: undefined,
|
1974
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1707
|
+
function useReducer<S, I, A extends AnyActionArg>(
|
1708
|
+
reducer: (prevState: S, ...args: A) => S,
|
1709
|
+
initialArg: I,
|
1710
|
+
init: (i: I) => S,
|
1711
|
+
): [S, ActionDispatch<A>];
|
1975
1712
|
/**
|
1976
1713
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
1977
1714
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
@@ -1982,7 +1719,7 @@ declare namespace React {
|
|
1982
1719
|
* @version 16.8.0
|
1983
1720
|
* @see {@link https://react.dev/reference/react/useRef}
|
1984
1721
|
*/
|
1985
|
-
function useRef<T>(initialValue: T):
|
1722
|
+
function useRef<T>(initialValue: T): RefObject<T>;
|
1986
1723
|
// convenience overload for refs given as a ref prop as they typically start with a null value
|
1987
1724
|
/**
|
1988
1725
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
@@ -1991,15 +1728,11 @@ declare namespace React {
|
|
1991
1728
|
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
1992
1729
|
* value around similar to how you’d use instance fields in classes.
|
1993
1730
|
*
|
1994
|
-
* Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
|
1995
|
-
* of the generic argument.
|
1996
|
-
*
|
1997
1731
|
* @version 16.8.0
|
1998
1732
|
* @see {@link https://react.dev/reference/react/useRef}
|
1999
1733
|
*/
|
2000
|
-
function useRef<T>(initialValue: T | null): RefObject<T>;
|
2001
|
-
// convenience overload for
|
2002
|
-
// has a default to stop it from defaulting to {} instead
|
1734
|
+
function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
1735
|
+
// convenience overload for undefined initialValue
|
2003
1736
|
/**
|
2004
1737
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
2005
1738
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
@@ -2010,7 +1743,7 @@ declare namespace React {
|
|
2010
1743
|
* @version 16.8.0
|
2011
1744
|
* @see {@link https://react.dev/reference/react/useRef}
|
2012
1745
|
*/
|
2013
|
-
function useRef<T
|
1746
|
+
function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
2014
1747
|
/**
|
2015
1748
|
* The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
|
2016
1749
|
* Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
|
@@ -2080,8 +1813,7 @@ declare namespace React {
|
|
2080
1813
|
// it's just the function name without the "use" prefix.
|
2081
1814
|
function useDebugValue<T>(value: T, format?: (value: T) => any): void;
|
2082
1815
|
|
2083
|
-
|
2084
|
-
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
1816
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
|
2085
1817
|
// strange definition to allow vscode to show documentation on the invocation
|
2086
1818
|
export interface TransitionStartFunction {
|
2087
1819
|
/**
|
@@ -2089,7 +1821,7 @@ declare namespace React {
|
|
2089
1821
|
*
|
2090
1822
|
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
2091
1823
|
*
|
2092
|
-
* @param callback A
|
1824
|
+
* @param callback A function which causes state updates that can be deferred.
|
2093
1825
|
*/
|
2094
1826
|
(callback: TransitionFunction): void;
|
2095
1827
|
}
|
@@ -2128,9 +1860,10 @@ declare namespace React {
|
|
2128
1860
|
/**
|
2129
1861
|
* Similar to `useTransition` but allows uses where hooks are not available.
|
2130
1862
|
*
|
2131
|
-
* @param callback A
|
1863
|
+
* @param callback A function which causes state updates that can be deferred.
|
2132
1864
|
*/
|
2133
1865
|
export function startTransition(scope: TransitionFunction): void;
|
1866
|
+
export function startTransition(scope: TransitionFunction): void;
|
2134
1867
|
|
2135
1868
|
/**
|
2136
1869
|
* Wrap any code rendering and triggering updates to your components into `act()` calls.
|
@@ -2143,6 +1876,11 @@ declare namespace React {
|
|
2143
1876
|
*
|
2144
1877
|
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
2145
1878
|
*/
|
1879
|
+
// NOTES
|
1880
|
+
// - the order of these signatures matters - typescript will check the signatures in source order.
|
1881
|
+
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
|
1882
|
+
// `strictNullChecks: false`.
|
1883
|
+
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
|
2146
1884
|
// While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
|
2147
1885
|
export function act(callback: () => VoidOrUndefinedOnly): void;
|
2148
1886
|
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
|
@@ -2170,6 +1908,32 @@ declare namespace React {
|
|
2170
1908
|
getServerSnapshot?: () => Snapshot,
|
2171
1909
|
): Snapshot;
|
2172
1910
|
|
1911
|
+
export function useOptimistic<State>(
|
1912
|
+
passthrough: State,
|
1913
|
+
): [State, (action: State | ((pendingState: State) => State)) => void];
|
1914
|
+
export function useOptimistic<State, Action>(
|
1915
|
+
passthrough: State,
|
1916
|
+
reducer: (state: State, action: Action) => State,
|
1917
|
+
): [State, (action: Action) => void];
|
1918
|
+
|
1919
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
1920
|
+
|
1921
|
+
export function use<T>(usable: Usable<T>): T;
|
1922
|
+
|
1923
|
+
export function useActionState<State>(
|
1924
|
+
action: (state: Awaited<State>) => State | Promise<State>,
|
1925
|
+
initialState: Awaited<State>,
|
1926
|
+
permalink?: string,
|
1927
|
+
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
1928
|
+
export function useActionState<State, Payload>(
|
1929
|
+
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
1930
|
+
initialState: Awaited<State>,
|
1931
|
+
permalink?: string,
|
1932
|
+
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
1933
|
+
|
1934
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
1935
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
1936
|
+
|
2173
1937
|
//
|
2174
1938
|
// Event System
|
2175
1939
|
// ----------------------------------------------------------------------
|
@@ -2337,6 +2101,11 @@ declare namespace React {
|
|
2337
2101
|
pseudoElement: string;
|
2338
2102
|
}
|
2339
2103
|
|
2104
|
+
interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
|
2105
|
+
oldState: "closed" | "open";
|
2106
|
+
newState: "closed" | "open";
|
2107
|
+
}
|
2108
|
+
|
2340
2109
|
interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
|
2341
2110
|
elapsedTime: number;
|
2342
2111
|
propertyName: string;
|
@@ -2364,6 +2133,7 @@ declare namespace React {
|
|
2364
2133
|
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
2365
2134
|
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
|
2366
2135
|
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
|
2136
|
+
type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
|
2367
2137
|
type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
|
2368
2138
|
|
2369
2139
|
//
|
@@ -2577,9 +2347,19 @@ declare namespace React {
|
|
2577
2347
|
onAnimationIteration?: AnimationEventHandler<T> | undefined;
|
2578
2348
|
onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
|
2579
2349
|
|
2350
|
+
// Toggle Events
|
2351
|
+
onToggle?: ToggleEventHandler<T> | undefined;
|
2352
|
+
onBeforeToggle?: ToggleEventHandler<T> | undefined;
|
2353
|
+
|
2580
2354
|
// Transition Events
|
2355
|
+
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
2356
|
+
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
2581
2357
|
onTransitionEnd?: TransitionEventHandler<T> | undefined;
|
2582
2358
|
onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
|
2359
|
+
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
2360
|
+
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
2361
|
+
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
2362
|
+
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
2583
2363
|
}
|
2584
2364
|
|
2585
2365
|
export interface CSSProperties extends CSS.Properties<string | number> {
|
@@ -2950,7 +2730,16 @@ declare namespace React {
|
|
2950
2730
|
security?: string | undefined;
|
2951
2731
|
unselectable?: "on" | "off" | undefined;
|
2952
2732
|
|
2733
|
+
// Popover API
|
2734
|
+
popover?: "" | "auto" | "manual" | undefined;
|
2735
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
|
2736
|
+
popoverTarget?: string | undefined;
|
2737
|
+
|
2953
2738
|
// Living Standard
|
2739
|
+
/**
|
2740
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
2741
|
+
*/
|
2742
|
+
inert?: boolean | undefined;
|
2954
2743
|
/**
|
2955
2744
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
2956
2745
|
* @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
|
@@ -2977,6 +2766,7 @@ declare namespace React {
|
|
2977
2766
|
action?:
|
2978
2767
|
| string
|
2979
2768
|
| undefined
|
2769
|
+
| ((formData: FormData) => void | Promise<void>)
|
2980
2770
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
2981
2771
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
2982
2772
|
];
|
@@ -3011,6 +2801,7 @@ declare namespace React {
|
|
3011
2801
|
formAction?:
|
3012
2802
|
| string
|
3013
2803
|
| undefined
|
2804
|
+
| ((formData: FormData) => void | Promise<void>)
|
3014
2805
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3015
2806
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3016
2807
|
];
|
@@ -3143,6 +2934,7 @@ declare namespace React {
|
|
3143
2934
|
form?: string | undefined;
|
3144
2935
|
formAction?:
|
3145
2936
|
| string
|
2937
|
+
| ((formData: FormData) => void | Promise<void>)
|
3146
2938
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3147
2939
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3148
2940
|
]
|
@@ -3176,7 +2968,6 @@ declare namespace React {
|
|
3176
2968
|
|
3177
2969
|
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
3178
2970
|
open?: boolean | undefined;
|
3179
|
-
onToggle?: ReactEventHandler<T> | undefined;
|
3180
2971
|
name?: string | undefined;
|
3181
2972
|
}
|
3182
2973
|
|
@@ -3209,6 +3000,7 @@ declare namespace React {
|
|
3209
3000
|
action?:
|
3210
3001
|
| string
|
3211
3002
|
| undefined
|
3003
|
+
| ((formData: FormData) => void | Promise<void>)
|
3212
3004
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3213
3005
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3214
3006
|
];
|
@@ -3364,6 +3156,7 @@ declare namespace React {
|
|
3364
3156
|
form?: string | undefined;
|
3365
3157
|
formAction?:
|
3366
3158
|
| string
|
3159
|
+
| ((formData: FormData) => void | Promise<void>)
|
3367
3160
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3368
3161
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3369
3162
|
]
|
@@ -3426,6 +3219,9 @@ declare namespace React {
|
|
3426
3219
|
sizes?: string | undefined;
|
3427
3220
|
type?: string | undefined;
|
3428
3221
|
charSet?: string | undefined;
|
3222
|
+
|
3223
|
+
// React props
|
3224
|
+
precedence?: string | undefined;
|
3429
3225
|
}
|
3430
3226
|
|
3431
3227
|
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -3560,6 +3356,10 @@ declare namespace React {
|
|
3560
3356
|
media?: string | undefined;
|
3561
3357
|
scoped?: boolean | undefined;
|
3562
3358
|
type?: string | undefined;
|
3359
|
+
|
3360
|
+
// React props
|
3361
|
+
href?: string | undefined;
|
3362
|
+
precedence?: string | undefined;
|
3563
3363
|
}
|
3564
3364
|
|
3565
3365
|
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -3947,259 +3747,184 @@ declare namespace React {
|
|
3947
3747
|
webpreferences?: string | undefined;
|
3948
3748
|
}
|
3949
3749
|
|
3950
|
-
//
|
3951
|
-
|
3952
|
-
|
3953
|
-
|
3954
|
-
|
3955
|
-
|
3956
|
-
|
3957
|
-
|
3958
|
-
|
3959
|
-
|
3960
|
-
|
3961
|
-
|
3962
|
-
|
3963
|
-
|
3964
|
-
|
3965
|
-
|
3966
|
-
|
3967
|
-
|
3968
|
-
|
3969
|
-
|
3970
|
-
|
3971
|
-
|
3972
|
-
|
3973
|
-
|
3974
|
-
|
3975
|
-
|
3976
|
-
|
3977
|
-
|
3978
|
-
|
3979
|
-
|
3980
|
-
|
3981
|
-
|
3982
|
-
|
3983
|
-
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
3987
|
-
|
3988
|
-
|
3989
|
-
|
3990
|
-
|
3991
|
-
|
3992
|
-
|
3993
|
-
|
3994
|
-
|
3995
|
-
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
3999
|
-
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4003
|
-
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4018
|
-
|
4019
|
-
|
4020
|
-
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
4037
|
-
|
4038
|
-
|
4039
|
-
|
4040
|
-
|
4041
|
-
|
4042
|
-
|
4043
|
-
|
4044
|
-
|
4045
|
-
|
4046
|
-
|
4047
|
-
|
4048
|
-
|
4049
|
-
|
4050
|
-
|
4051
|
-
|
4052
|
-
|
4053
|
-
|
4054
|
-
|
4055
|
-
|
4056
|
-
|
4057
|
-
|
4058
|
-
|
4059
|
-
|
4060
|
-
|
4061
|
-
|
4062
|
-
|
4063
|
-
|
4064
|
-
|
4065
|
-
|
4066
|
-
|
4067
|
-
|
4068
|
-
|
4069
|
-
"
|
4070
|
-
|
4071
|
-
|
4072
|
-
|
4073
|
-
|
4074
|
-
|
4075
|
-
|
4076
|
-
|
4077
|
-
|
4078
|
-
|
4079
|
-
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4087
|
-
|
4088
|
-
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4110
|
-
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
|
4119
|
-
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4124
|
-
|
4125
|
-
|
4126
|
-
|
4127
|
-
|
4128
|
-
tspan: SVGFactory;
|
4129
|
-
use: SVGFactory;
|
4130
|
-
view: SVGFactory;
|
4131
|
-
}
|
4132
|
-
|
4133
|
-
interface ReactDOM extends ReactHTML, ReactSVG {}
|
4134
|
-
|
4135
|
-
//
|
4136
|
-
// React.PropTypes
|
4137
|
-
// ----------------------------------------------------------------------
|
4138
|
-
|
4139
|
-
/**
|
4140
|
-
* @deprecated Use `Validator` from the ´prop-types` instead.
|
4141
|
-
*/
|
4142
|
-
type Validator<T> = PropTypes.Validator<T>;
|
4143
|
-
|
4144
|
-
/**
|
4145
|
-
* @deprecated Use `Requireable` from the ´prop-types` instead.
|
4146
|
-
*/
|
4147
|
-
type Requireable<T> = PropTypes.Requireable<T>;
|
4148
|
-
|
4149
|
-
/**
|
4150
|
-
* @deprecated Use `ValidationMap` from the ´prop-types` instead.
|
4151
|
-
*/
|
4152
|
-
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
4153
|
-
|
4154
|
-
/**
|
4155
|
-
* @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
|
4156
|
-
*/
|
4157
|
-
type WeakValidationMap<T> = {
|
4158
|
-
[K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
|
4159
|
-
: undefined extends T[K] ? Validator<T[K] | null | undefined>
|
4160
|
-
: Validator<T[K]>;
|
4161
|
-
};
|
4162
|
-
|
4163
|
-
/**
|
4164
|
-
* @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
|
4165
|
-
*/
|
4166
|
-
interface ReactPropTypes {
|
4167
|
-
any: typeof PropTypes.any;
|
4168
|
-
array: typeof PropTypes.array;
|
4169
|
-
bool: typeof PropTypes.bool;
|
4170
|
-
func: typeof PropTypes.func;
|
4171
|
-
number: typeof PropTypes.number;
|
4172
|
-
object: typeof PropTypes.object;
|
4173
|
-
string: typeof PropTypes.string;
|
4174
|
-
node: typeof PropTypes.node;
|
4175
|
-
element: typeof PropTypes.element;
|
4176
|
-
instanceOf: typeof PropTypes.instanceOf;
|
4177
|
-
oneOf: typeof PropTypes.oneOf;
|
4178
|
-
oneOfType: typeof PropTypes.oneOfType;
|
4179
|
-
arrayOf: typeof PropTypes.arrayOf;
|
4180
|
-
objectOf: typeof PropTypes.objectOf;
|
4181
|
-
shape: typeof PropTypes.shape;
|
4182
|
-
exact: typeof PropTypes.exact;
|
4183
|
-
}
|
4184
|
-
|
4185
|
-
//
|
4186
|
-
// React.Children
|
4187
|
-
// ----------------------------------------------------------------------
|
4188
|
-
|
4189
|
-
/**
|
4190
|
-
* @deprecated - Use `typeof React.Children` instead.
|
4191
|
-
*/
|
4192
|
-
// Sync with type of `const Children`.
|
4193
|
-
interface ReactChildren {
|
4194
|
-
map<T, C>(
|
4195
|
-
children: C | readonly C[],
|
4196
|
-
fn: (child: C, index: number) => T,
|
4197
|
-
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
4198
|
-
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
4199
|
-
count(children: any): number;
|
4200
|
-
only<C>(children: C): C extends any[] ? never : C;
|
4201
|
-
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
4202
|
-
}
|
3750
|
+
// TODO: Move to react-dom
|
3751
|
+
type HTMLElementType =
|
3752
|
+
| "a"
|
3753
|
+
| "abbr"
|
3754
|
+
| "address"
|
3755
|
+
| "area"
|
3756
|
+
| "article"
|
3757
|
+
| "aside"
|
3758
|
+
| "audio"
|
3759
|
+
| "b"
|
3760
|
+
| "base"
|
3761
|
+
| "bdi"
|
3762
|
+
| "bdo"
|
3763
|
+
| "big"
|
3764
|
+
| "blockquote"
|
3765
|
+
| "body"
|
3766
|
+
| "br"
|
3767
|
+
| "button"
|
3768
|
+
| "canvas"
|
3769
|
+
| "caption"
|
3770
|
+
| "center"
|
3771
|
+
| "cite"
|
3772
|
+
| "code"
|
3773
|
+
| "col"
|
3774
|
+
| "colgroup"
|
3775
|
+
| "data"
|
3776
|
+
| "datalist"
|
3777
|
+
| "dd"
|
3778
|
+
| "del"
|
3779
|
+
| "details"
|
3780
|
+
| "dfn"
|
3781
|
+
| "dialog"
|
3782
|
+
| "div"
|
3783
|
+
| "dl"
|
3784
|
+
| "dt"
|
3785
|
+
| "em"
|
3786
|
+
| "embed"
|
3787
|
+
| "fieldset"
|
3788
|
+
| "figcaption"
|
3789
|
+
| "figure"
|
3790
|
+
| "footer"
|
3791
|
+
| "form"
|
3792
|
+
| "h1"
|
3793
|
+
| "h2"
|
3794
|
+
| "h3"
|
3795
|
+
| "h4"
|
3796
|
+
| "h5"
|
3797
|
+
| "h6"
|
3798
|
+
| "head"
|
3799
|
+
| "header"
|
3800
|
+
| "hgroup"
|
3801
|
+
| "hr"
|
3802
|
+
| "html"
|
3803
|
+
| "i"
|
3804
|
+
| "iframe"
|
3805
|
+
| "img"
|
3806
|
+
| "input"
|
3807
|
+
| "ins"
|
3808
|
+
| "kbd"
|
3809
|
+
| "keygen"
|
3810
|
+
| "label"
|
3811
|
+
| "legend"
|
3812
|
+
| "li"
|
3813
|
+
| "link"
|
3814
|
+
| "main"
|
3815
|
+
| "map"
|
3816
|
+
| "mark"
|
3817
|
+
| "menu"
|
3818
|
+
| "menuitem"
|
3819
|
+
| "meta"
|
3820
|
+
| "meter"
|
3821
|
+
| "nav"
|
3822
|
+
| "noscript"
|
3823
|
+
| "object"
|
3824
|
+
| "ol"
|
3825
|
+
| "optgroup"
|
3826
|
+
| "option"
|
3827
|
+
| "output"
|
3828
|
+
| "p"
|
3829
|
+
| "param"
|
3830
|
+
| "picture"
|
3831
|
+
| "pre"
|
3832
|
+
| "progress"
|
3833
|
+
| "q"
|
3834
|
+
| "rp"
|
3835
|
+
| "rt"
|
3836
|
+
| "ruby"
|
3837
|
+
| "s"
|
3838
|
+
| "samp"
|
3839
|
+
| "search"
|
3840
|
+
| "slot"
|
3841
|
+
| "script"
|
3842
|
+
| "section"
|
3843
|
+
| "select"
|
3844
|
+
| "small"
|
3845
|
+
| "source"
|
3846
|
+
| "span"
|
3847
|
+
| "strong"
|
3848
|
+
| "style"
|
3849
|
+
| "sub"
|
3850
|
+
| "summary"
|
3851
|
+
| "sup"
|
3852
|
+
| "table"
|
3853
|
+
| "template"
|
3854
|
+
| "tbody"
|
3855
|
+
| "td"
|
3856
|
+
| "textarea"
|
3857
|
+
| "tfoot"
|
3858
|
+
| "th"
|
3859
|
+
| "thead"
|
3860
|
+
| "time"
|
3861
|
+
| "title"
|
3862
|
+
| "tr"
|
3863
|
+
| "track"
|
3864
|
+
| "u"
|
3865
|
+
| "ul"
|
3866
|
+
| "var"
|
3867
|
+
| "video"
|
3868
|
+
| "wbr"
|
3869
|
+
| "webview";
|
3870
|
+
|
3871
|
+
// TODO: Move to react-dom
|
3872
|
+
type SVGElementType =
|
3873
|
+
| "animate"
|
3874
|
+
| "circle"
|
3875
|
+
| "clipPath"
|
3876
|
+
| "defs"
|
3877
|
+
| "desc"
|
3878
|
+
| "ellipse"
|
3879
|
+
| "feBlend"
|
3880
|
+
| "feColorMatrix"
|
3881
|
+
| "feComponentTransfer"
|
3882
|
+
| "feComposite"
|
3883
|
+
| "feConvolveMatrix"
|
3884
|
+
| "feDiffuseLighting"
|
3885
|
+
| "feDisplacementMap"
|
3886
|
+
| "feDistantLight"
|
3887
|
+
| "feDropShadow"
|
3888
|
+
| "feFlood"
|
3889
|
+
| "feFuncA"
|
3890
|
+
| "feFuncB"
|
3891
|
+
| "feFuncG"
|
3892
|
+
| "feFuncR"
|
3893
|
+
| "feGaussianBlur"
|
3894
|
+
| "feImage"
|
3895
|
+
| "feMerge"
|
3896
|
+
| "feMergeNode"
|
3897
|
+
| "feMorphology"
|
3898
|
+
| "feOffset"
|
3899
|
+
| "fePointLight"
|
3900
|
+
| "feSpecularLighting"
|
3901
|
+
| "feSpotLight"
|
3902
|
+
| "feTile"
|
3903
|
+
| "feTurbulence"
|
3904
|
+
| "filter"
|
3905
|
+
| "foreignObject"
|
3906
|
+
| "g"
|
3907
|
+
| "image"
|
3908
|
+
| "line"
|
3909
|
+
| "linearGradient"
|
3910
|
+
| "marker"
|
3911
|
+
| "mask"
|
3912
|
+
| "metadata"
|
3913
|
+
| "path"
|
3914
|
+
| "pattern"
|
3915
|
+
| "polygon"
|
3916
|
+
| "polyline"
|
3917
|
+
| "radialGradient"
|
3918
|
+
| "rect"
|
3919
|
+
| "stop"
|
3920
|
+
| "svg"
|
3921
|
+
| "switch"
|
3922
|
+
| "symbol"
|
3923
|
+
| "text"
|
3924
|
+
| "textPath"
|
3925
|
+
| "tspan"
|
3926
|
+
| "use"
|
3927
|
+
| "view";
|
4203
3928
|
|
4204
3929
|
//
|
4205
3930
|
// Browser Interfaces
|
@@ -4241,68 +3966,6 @@ declare namespace React {
|
|
4241
3966
|
}
|
4242
3967
|
|
4243
3968
|
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
4244
|
-
namespace JSX {
|
4245
|
-
type ElementType = GlobalJSXElementType;
|
4246
|
-
interface Element extends GlobalJSXElement {}
|
4247
|
-
interface ElementClass extends GlobalJSXElementClass {}
|
4248
|
-
interface ElementAttributesProperty extends GlobalJSXElementAttributesProperty {}
|
4249
|
-
interface ElementChildrenAttribute extends GlobalJSXElementChildrenAttribute {}
|
4250
|
-
|
4251
|
-
type LibraryManagedAttributes<C, P> = GlobalJSXLibraryManagedAttributes<C, P>;
|
4252
|
-
|
4253
|
-
interface IntrinsicAttributes extends GlobalJSXIntrinsicAttributes {}
|
4254
|
-
interface IntrinsicClassAttributes<T> extends GlobalJSXIntrinsicClassAttributes<T> {}
|
4255
|
-
interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
|
4256
|
-
}
|
4257
|
-
}
|
4258
|
-
|
4259
|
-
// naked 'any' type in a conditional type will short circuit and union both the then/else branches
|
4260
|
-
// so boolean is only resolved for T = any
|
4261
|
-
type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
4262
|
-
|
4263
|
-
type ExactlyAnyPropertyKeys<T> = { [K in keyof T]: IsExactlyAny<T[K]> extends true ? K : never }[keyof T];
|
4264
|
-
type NotExactlyAnyPropertyKeys<T> = Exclude<keyof T, ExactlyAnyPropertyKeys<T>>;
|
4265
|
-
|
4266
|
-
// Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any
|
4267
|
-
type MergePropTypes<P, T> =
|
4268
|
-
// Distribute over P in case it is a union type
|
4269
|
-
P extends any
|
4270
|
-
// If props is type any, use propTypes definitions
|
4271
|
-
? IsExactlyAny<P> extends true ? T
|
4272
|
-
// If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
|
4273
|
-
: string extends keyof P ? P
|
4274
|
-
// Prefer declared types which are not exactly any
|
4275
|
-
:
|
4276
|
-
& Pick<P, NotExactlyAnyPropertyKeys<P>>
|
4277
|
-
// For props which are exactly any, use the type inferred from propTypes if present
|
4278
|
-
& Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
|
4279
|
-
// Keep leftover props not specified in propTypes
|
4280
|
-
& Pick<P, Exclude<keyof P, keyof T>>
|
4281
|
-
: never;
|
4282
|
-
|
4283
|
-
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
4284
|
-
|
4285
|
-
// Any prop that has a default prop becomes optional, but its type is unchanged
|
4286
|
-
// Undeclared default props are augmented into the resulting allowable attributes
|
4287
|
-
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
4288
|
-
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
4289
|
-
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
4290
|
-
:
|
4291
|
-
& Pick<P, Exclude<keyof P, keyof D>>
|
4292
|
-
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
4293
|
-
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
4294
|
-
: never;
|
4295
|
-
|
4296
|
-
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D }
|
4297
|
-
? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
|
4298
|
-
: C extends { propTypes: infer T } ? MergePropTypes<P, PropTypes.InferProps<T>>
|
4299
|
-
: C extends { defaultProps: infer D } ? Defaultize<P, D>
|
4300
|
-
: P;
|
4301
|
-
|
4302
|
-
declare global {
|
4303
|
-
/**
|
4304
|
-
* @deprecated Use `React.JSX` instead of the global `JSX` namespace.
|
4305
|
-
*/
|
4306
3969
|
namespace JSX {
|
4307
3970
|
// We don't just alias React.ElementType because React.ElementType
|
4308
3971
|
// historically does more than we need it to.
|
@@ -4526,18 +4189,18 @@ declare global {
|
|
4526
4189
|
}
|
4527
4190
|
}
|
4528
4191
|
|
4529
|
-
|
4530
|
-
// But we can't access global.JSX so we need to create these aliases instead.
|
4531
|
-
// Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
|
4532
|
-
type GlobalJSXElementType = JSX.ElementType;
|
4533
|
-
interface GlobalJSXElement extends JSX.Element {}
|
4534
|
-
interface GlobalJSXElementClass extends JSX.ElementClass {}
|
4535
|
-
interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
|
4536
|
-
interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
|
4537
|
-
|
4538
|
-
type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
|
4192
|
+
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
4539
4193
|
|
4540
|
-
|
4541
|
-
|
4194
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
4195
|
+
// Undeclared default props are augmented into the resulting allowable attributes
|
4196
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
4197
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
4198
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
4199
|
+
:
|
4200
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
4201
|
+
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
4202
|
+
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
4203
|
+
: never;
|
4542
4204
|
|
4543
|
-
|
4205
|
+
type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
|
4206
|
+
: P;
|