@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/ts5.0/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
|
) => ReactElement<any, any> | null)
|
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) => ReactElement | null)
|
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
|
* For internal usage only.
|
444
392
|
* Different release channels declare additional types of ReactNode this particular release channel accepts.
|
@@ -480,6 +428,7 @@ declare namespace React {
|
|
480
428
|
| ReactElement
|
481
429
|
| string
|
482
430
|
| number
|
431
|
+
| bigint
|
483
432
|
| Iterable<ReactNode>
|
484
433
|
| ReactPortal
|
485
434
|
| boolean
|
@@ -487,36 +436,13 @@ declare namespace React {
|
|
487
436
|
| undefined
|
488
437
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
489
438
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
490
|
-
]
|
439
|
+
]
|
440
|
+
| Promise<AwaitedReactNode>;
|
491
441
|
|
492
442
|
//
|
493
443
|
// Top Level API
|
494
444
|
// ----------------------------------------------------------------------
|
495
445
|
|
496
|
-
// DOM Elements
|
497
|
-
/** @deprecated */
|
498
|
-
function createFactory<T extends HTMLElement>(
|
499
|
-
type: keyof ReactHTML,
|
500
|
-
): HTMLFactory<T>;
|
501
|
-
/** @deprecated */
|
502
|
-
function createFactory(
|
503
|
-
type: keyof ReactSVG,
|
504
|
-
): SVGFactory;
|
505
|
-
/** @deprecated */
|
506
|
-
function createFactory<P extends DOMAttributes<T>, T extends Element>(
|
507
|
-
type: string,
|
508
|
-
): DOMFactory<P, T>;
|
509
|
-
|
510
|
-
// Custom components
|
511
|
-
/** @deprecated */
|
512
|
-
function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
|
513
|
-
/** @deprecated */
|
514
|
-
function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
515
|
-
type: ClassType<P, T, C>,
|
516
|
-
): CFactory<P, T>;
|
517
|
-
/** @deprecated */
|
518
|
-
function createFactory<P>(type: ComponentClass<P>): Factory<P>;
|
519
|
-
|
520
446
|
// DOM Elements
|
521
447
|
// TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
|
522
448
|
function createElement(
|
@@ -525,12 +451,12 @@ declare namespace React {
|
|
525
451
|
...children: ReactNode[]
|
526
452
|
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
527
453
|
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
528
|
-
type:
|
454
|
+
type: HTMLElementType,
|
529
455
|
props?: ClassAttributes<T> & P | null,
|
530
456
|
...children: ReactNode[]
|
531
457
|
): DetailedReactHTMLElement<P, T>;
|
532
458
|
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
533
|
-
type:
|
459
|
+
type: SVGElementType,
|
534
460
|
props?: ClassAttributes<T> & P | null,
|
535
461
|
...children: ReactNode[]
|
536
462
|
): ReactSVGElement;
|
@@ -659,7 +585,6 @@ declare namespace React {
|
|
659
585
|
* @template P The props the component accepts.
|
660
586
|
*/
|
661
587
|
interface ProviderExoticComponent<P> extends ExoticComponent<P> {
|
662
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
663
588
|
}
|
664
589
|
|
665
590
|
/**
|
@@ -741,7 +666,7 @@ declare namespace React {
|
|
741
666
|
* const ThemeContext = createContext('light');
|
742
667
|
* ```
|
743
668
|
*/
|
744
|
-
interface Context<T> {
|
669
|
+
interface Context<T> extends Provider<T> {
|
745
670
|
Provider: Provider<T>;
|
746
671
|
Consumer: Consumer<T>;
|
747
672
|
/**
|
@@ -770,6 +695,13 @@ declare namespace React {
|
|
770
695
|
* import { createContext } from 'react';
|
771
696
|
*
|
772
697
|
* const ThemeContext = createContext('light');
|
698
|
+
* function App() {
|
699
|
+
* return (
|
700
|
+
* <ThemeContext value="dark">
|
701
|
+
* <Toolbar />
|
702
|
+
* </ThemeContext>
|
703
|
+
* );
|
704
|
+
* }
|
773
705
|
* ```
|
774
706
|
*/
|
775
707
|
function createContext<T>(
|
@@ -780,9 +712,6 @@ declare namespace React {
|
|
780
712
|
|
781
713
|
function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
|
782
714
|
|
783
|
-
/**
|
784
|
-
* Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
|
785
|
-
*/
|
786
715
|
const Children: {
|
787
716
|
map<T, C>(
|
788
717
|
children: C | readonly C[],
|
@@ -988,6 +917,12 @@ declare namespace React {
|
|
988
917
|
*/
|
989
918
|
static contextType?: Context<any> | undefined;
|
990
919
|
|
920
|
+
/**
|
921
|
+
* Ignored by React.
|
922
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
923
|
+
*/
|
924
|
+
static propTypes?: any;
|
925
|
+
|
991
926
|
/**
|
992
927
|
* If using the new style context, re-declare this in your class to be the
|
993
928
|
* `React.ContextType` of your `static contextType`.
|
@@ -1006,12 +941,8 @@ declare namespace React {
|
|
1006
941
|
*/
|
1007
942
|
context: unknown;
|
1008
943
|
|
944
|
+
// Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
|
1009
945
|
constructor(props: P);
|
1010
|
-
/**
|
1011
|
-
* @deprecated
|
1012
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}
|
1013
|
-
*/
|
1014
|
-
constructor(props: P, context: any);
|
1015
946
|
|
1016
947
|
// We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
|
1017
948
|
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
|
@@ -1026,14 +957,6 @@ declare namespace React {
|
|
1026
957
|
|
1027
958
|
readonly props: Readonly<P>;
|
1028
959
|
state: Readonly<S>;
|
1029
|
-
/**
|
1030
|
-
* @deprecated
|
1031
|
-
*
|
1032
|
-
* @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
|
1033
|
-
*/
|
1034
|
-
refs: {
|
1035
|
-
[key: string]: ReactInstance;
|
1036
|
-
};
|
1037
960
|
}
|
1038
961
|
|
1039
962
|
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
|
@@ -1050,10 +973,6 @@ declare namespace React {
|
|
1050
973
|
getInitialState?(): S;
|
1051
974
|
}
|
1052
975
|
|
1053
|
-
interface ChildContextProvider<CC> {
|
1054
|
-
getChildContext(): CC;
|
1055
|
-
}
|
1056
|
-
|
1057
976
|
//
|
1058
977
|
// Class Interfaces
|
1059
978
|
// ----------------------------------------------------------------------
|
@@ -1118,58 +1037,12 @@ declare namespace React {
|
|
1118
1037
|
* ```
|
1119
1038
|
*/
|
1120
1039
|
interface FunctionComponent<P = {}> {
|
1121
|
-
(
|
1122
|
-
props: P,
|
1123
|
-
/**
|
1124
|
-
* @deprecated
|
1125
|
-
*
|
1126
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
1127
|
-
*/
|
1128
|
-
deprecatedLegacyContext?: any,
|
1129
|
-
): ReactElement<any, any> | null;
|
1130
|
-
/**
|
1131
|
-
* Used to declare the types of the props accepted by the
|
1132
|
-
* component. These types will be checked during rendering
|
1133
|
-
* and in development only.
|
1134
|
-
*
|
1135
|
-
* We recommend using TypeScript instead of checking prop
|
1136
|
-
* types at runtime.
|
1137
|
-
*
|
1138
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
1139
|
-
*/
|
1140
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
1040
|
+
(props: P): ReactElement<any, any> | null;
|
1141
1041
|
/**
|
1142
|
-
*
|
1143
|
-
*
|
1144
|
-
* Lets you specify which legacy context is consumed by
|
1145
|
-
* this component.
|
1146
|
-
*
|
1147
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
1042
|
+
* Ignored by React.
|
1043
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1148
1044
|
*/
|
1149
|
-
|
1150
|
-
/**
|
1151
|
-
* Used to define default values for the props accepted by
|
1152
|
-
* the component.
|
1153
|
-
*
|
1154
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
1155
|
-
*
|
1156
|
-
* @example
|
1157
|
-
*
|
1158
|
-
* ```tsx
|
1159
|
-
* type Props = { name?: string }
|
1160
|
-
*
|
1161
|
-
* const MyComponent: FC<Props> = (props) => {
|
1162
|
-
* return <div>{props.name}</div>
|
1163
|
-
* }
|
1164
|
-
*
|
1165
|
-
* MyComponent.defaultProps = {
|
1166
|
-
* name: 'John Doe'
|
1167
|
-
* }
|
1168
|
-
* ```
|
1169
|
-
*
|
1170
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
1171
|
-
*/
|
1172
|
-
defaultProps?: Partial<P> | undefined;
|
1045
|
+
propTypes?: any;
|
1173
1046
|
/**
|
1174
1047
|
* Used in debugging messages. You might want to set it
|
1175
1048
|
* explicitly if you want to display a different name for
|
@@ -1191,38 +1064,6 @@ declare namespace React {
|
|
1191
1064
|
displayName?: string | undefined;
|
1192
1065
|
}
|
1193
1066
|
|
1194
|
-
/**
|
1195
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
1196
|
-
*
|
1197
|
-
* @see {@link React.FunctionComponent}
|
1198
|
-
* @alias {@link VoidFunctionComponent}
|
1199
|
-
*/
|
1200
|
-
type VFC<P = {}> = VoidFunctionComponent<P>;
|
1201
|
-
|
1202
|
-
/**
|
1203
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
1204
|
-
*
|
1205
|
-
* @see {@link React.FunctionComponent}
|
1206
|
-
*/
|
1207
|
-
interface VoidFunctionComponent<P = {}> {
|
1208
|
-
(
|
1209
|
-
props: P,
|
1210
|
-
/**
|
1211
|
-
* @deprecated
|
1212
|
-
*
|
1213
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
1214
|
-
*/
|
1215
|
-
deprecatedLegacyContext?: any,
|
1216
|
-
): ReactElement<any, any> | null;
|
1217
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
1218
|
-
contextTypes?: ValidationMap<any> | undefined;
|
1219
|
-
/**
|
1220
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
1221
|
-
*/
|
1222
|
-
defaultProps?: Partial<P> | undefined;
|
1223
|
-
displayName?: string | undefined;
|
1224
|
-
}
|
1225
|
-
|
1226
1067
|
/**
|
1227
1068
|
* The type of the ref received by a {@link ForwardRefRenderFunction}.
|
1228
1069
|
*
|
@@ -1257,19 +1098,10 @@ declare namespace React {
|
|
1257
1098
|
*/
|
1258
1099
|
displayName?: string | undefined;
|
1259
1100
|
/**
|
1260
|
-
*
|
1261
|
-
*
|
1262
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
1263
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
1101
|
+
* Ignored by React.
|
1102
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1264
1103
|
*/
|
1265
|
-
|
1266
|
-
/**
|
1267
|
-
* propTypes are not supported on render functions passed to forwardRef.
|
1268
|
-
*
|
1269
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
1270
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
1271
|
-
*/
|
1272
|
-
propTypes?: never | undefined;
|
1104
|
+
propTypes?: any;
|
1273
1105
|
}
|
1274
1106
|
|
1275
1107
|
/**
|
@@ -1279,48 +1111,14 @@ declare namespace React {
|
|
1279
1111
|
* @template S The internal state of the component.
|
1280
1112
|
*/
|
1281
1113
|
interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
|
1282
|
-
|
1283
|
-
|
1284
|
-
/**
|
1285
|
-
* @deprecated
|
1286
|
-
*
|
1287
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
1288
|
-
*/
|
1289
|
-
deprecatedLegacyContext?: any,
|
1290
|
-
): Component<P, S>;
|
1114
|
+
// constructor signature must match React.Component
|
1115
|
+
new(props: P): Component<P, S>;
|
1291
1116
|
/**
|
1292
|
-
*
|
1293
|
-
*
|
1294
|
-
* and in development only.
|
1295
|
-
*
|
1296
|
-
* We recommend using TypeScript instead of checking prop
|
1297
|
-
* types at runtime.
|
1298
|
-
*
|
1299
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
1117
|
+
* Ignored by React.
|
1118
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1300
1119
|
*/
|
1301
|
-
propTypes?:
|
1120
|
+
propTypes?: any;
|
1302
1121
|
contextType?: Context<any> | undefined;
|
1303
|
-
/**
|
1304
|
-
* @deprecated use {@link ComponentClass.contextType} instead
|
1305
|
-
*
|
1306
|
-
* Lets you specify which legacy context is consumed by
|
1307
|
-
* this component.
|
1308
|
-
*
|
1309
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
1310
|
-
*/
|
1311
|
-
contextTypes?: ValidationMap<any> | undefined;
|
1312
|
-
/**
|
1313
|
-
* @deprecated
|
1314
|
-
*
|
1315
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
|
1316
|
-
*/
|
1317
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
1318
|
-
/**
|
1319
|
-
* Used to define default values for the props accepted by
|
1320
|
-
* the component.
|
1321
|
-
*
|
1322
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
1323
|
-
*/
|
1324
1122
|
defaultProps?: Partial<P> | undefined;
|
1325
1123
|
/**
|
1326
1124
|
* Used in debugging messages. You might want to set it
|
@@ -1339,7 +1137,7 @@ declare namespace React {
|
|
1339
1137
|
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
1340
1138
|
*/
|
1341
1139
|
interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
|
1342
|
-
new(props: P
|
1140
|
+
new(props: P): ClassicComponent<P, ComponentState>;
|
1343
1141
|
getDefaultProps?(): P;
|
1344
1142
|
}
|
1345
1143
|
|
@@ -1354,7 +1152,7 @@ declare namespace React {
|
|
1354
1152
|
*/
|
1355
1153
|
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
1356
1154
|
& C
|
1357
|
-
& (new(props: P
|
1155
|
+
& (new(props: P) => T);
|
1358
1156
|
|
1359
1157
|
//
|
1360
1158
|
// Component Specs and Lifecycle
|
@@ -1378,7 +1176,7 @@ declare namespace React {
|
|
1378
1176
|
* If false is returned, {@link Component.render}, `componentWillUpdate`
|
1379
1177
|
* and `componentDidUpdate` will not be called.
|
1380
1178
|
*/
|
1381
|
-
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S
|
1179
|
+
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): boolean;
|
1382
1180
|
/**
|
1383
1181
|
* Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
|
1384
1182
|
* cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
|
@@ -1477,7 +1275,7 @@ declare namespace React {
|
|
1477
1275
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
|
1478
1276
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1479
1277
|
*/
|
1480
|
-
componentWillReceiveProps?(nextProps: Readonly<P
|
1278
|
+
componentWillReceiveProps?(nextProps: Readonly<P>): void;
|
1481
1279
|
/**
|
1482
1280
|
* Called when the component may be receiving new props.
|
1483
1281
|
* React may call this even if props have not changed, so be sure to compare new and existing
|
@@ -1495,7 +1293,7 @@ declare namespace React {
|
|
1495
1293
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
|
1496
1294
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1497
1295
|
*/
|
1498
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P
|
1296
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>): void;
|
1499
1297
|
/**
|
1500
1298
|
* Called immediately before rendering when new props or state is received. Not called for the initial render.
|
1501
1299
|
*
|
@@ -1509,7 +1307,7 @@ declare namespace React {
|
|
1509
1307
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
|
1510
1308
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1511
1309
|
*/
|
1512
|
-
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S
|
1310
|
+
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
|
1513
1311
|
/**
|
1514
1312
|
* Called immediately before rendering when new props or state is received. Not called for the initial render.
|
1515
1313
|
*
|
@@ -1525,41 +1323,10 @@ declare namespace React {
|
|
1525
1323
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
|
1526
1324
|
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1527
1325
|
*/
|
1528
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S
|
1529
|
-
}
|
1530
|
-
|
1531
|
-
/**
|
1532
|
-
* @deprecated
|
1533
|
-
*
|
1534
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
1535
|
-
*/
|
1536
|
-
interface Mixin<P, S> extends ComponentLifecycle<P, S> {
|
1537
|
-
mixins?: Array<Mixin<P, S>> | undefined;
|
1538
|
-
statics?: {
|
1539
|
-
[key: string]: any;
|
1540
|
-
} | undefined;
|
1541
|
-
|
1542
|
-
displayName?: string | undefined;
|
1543
|
-
propTypes?: ValidationMap<any> | undefined;
|
1544
|
-
contextTypes?: ValidationMap<any> | undefined;
|
1545
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
1546
|
-
|
1547
|
-
getDefaultProps?(): P;
|
1548
|
-
getInitialState?(): S;
|
1326
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
|
1549
1327
|
}
|
1550
1328
|
|
1551
|
-
|
1552
|
-
* @deprecated
|
1553
|
-
*
|
1554
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
1555
|
-
*/
|
1556
|
-
interface ComponentSpec<P, S> extends Mixin<P, S> {
|
1557
|
-
render(): ReactNode;
|
1558
|
-
|
1559
|
-
[propertyName: string]: any;
|
1560
|
-
}
|
1561
|
-
|
1562
|
-
function createRef<T>(): RefObject<T>;
|
1329
|
+
function createRef<T>(): RefObject<T | null>;
|
1563
1330
|
|
1564
1331
|
/**
|
1565
1332
|
* The type of the component returned from {@link forwardRef}.
|
@@ -1570,10 +1337,10 @@ declare namespace React {
|
|
1570
1337
|
*/
|
1571
1338
|
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
1572
1339
|
/**
|
1573
|
-
*
|
1340
|
+
* Ignored by React.
|
1341
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1574
1342
|
*/
|
1575
|
-
|
1576
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
1343
|
+
propTypes?: any;
|
1577
1344
|
}
|
1578
1345
|
|
1579
1346
|
/**
|
@@ -1610,23 +1377,18 @@ declare namespace React {
|
|
1610
1377
|
/**
|
1611
1378
|
* Omits the 'ref' attribute from the given props object.
|
1612
1379
|
*
|
1613
|
-
* @template
|
1380
|
+
* @template Props The props object type.
|
1614
1381
|
*/
|
1615
|
-
type PropsWithoutRef<
|
1382
|
+
type PropsWithoutRef<Props> =
|
1616
1383
|
// Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
|
1617
1384
|
// see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
1618
1385
|
// https://github.com/Microsoft/TypeScript/issues/28339
|
1619
|
-
|
1620
|
-
/**
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
? P extends { ref?: infer R | undefined }
|
1626
|
-
? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
1627
|
-
: P
|
1628
|
-
: P
|
1629
|
-
: P;
|
1386
|
+
Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
|
1387
|
+
/**
|
1388
|
+
* Ensures that the props do not include string ref, which cannot be forwarded
|
1389
|
+
* @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
|
1390
|
+
*/
|
1391
|
+
type PropsWithRef<Props> = Props;
|
1630
1392
|
|
1631
1393
|
type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
|
1632
1394
|
|
@@ -1658,7 +1420,7 @@ declare namespace React {
|
|
1658
1420
|
* ```
|
1659
1421
|
*/
|
1660
1422
|
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
1661
|
-
JSXElementConstructor<infer
|
1423
|
+
JSXElementConstructor<infer Props> ? Props
|
1662
1424
|
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
1663
1425
|
: {};
|
1664
1426
|
|
@@ -1685,9 +1447,11 @@ declare namespace React {
|
|
1685
1447
|
* type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
|
1686
1448
|
* ```
|
1687
1449
|
*/
|
1688
|
-
type ComponentPropsWithRef<T extends ElementType> = T extends
|
1689
|
-
|
1690
|
-
:
|
1450
|
+
type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
|
1451
|
+
// If it's a class i.e. newable we're dealing with a class component
|
1452
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
1453
|
+
: Props
|
1454
|
+
: ComponentProps<T>;
|
1691
1455
|
/**
|
1692
1456
|
* Used to retrieve the props a custom component accepts with its ref.
|
1693
1457
|
*
|
@@ -1704,9 +1468,10 @@ declare namespace React {
|
|
1704
1468
|
* type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
|
1705
1469
|
* ```
|
1706
1470
|
*/
|
1707
|
-
type CustomComponentPropsWithRef<T extends ComponentType> = T extends
|
1708
|
-
|
1709
|
-
|
1471
|
+
type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
|
1472
|
+
// If it's a class i.e. newable we're dealing with a class component
|
1473
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
1474
|
+
: Props
|
1710
1475
|
: never;
|
1711
1476
|
|
1712
1477
|
/**
|
@@ -1734,10 +1499,24 @@ declare namespace React {
|
|
1734
1499
|
*/
|
1735
1500
|
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
1736
1501
|
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1502
|
+
/**
|
1503
|
+
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
1504
|
+
*
|
1505
|
+
* @template C The component type.
|
1506
|
+
*
|
1507
|
+
* @example
|
1508
|
+
*
|
1509
|
+
* ```tsx
|
1510
|
+
* type MyComponentRef = React.ElementRef<typeof MyComponent>;
|
1511
|
+
* ```
|
1512
|
+
*
|
1513
|
+
* @example
|
1514
|
+
*
|
1515
|
+
* ```tsx
|
1516
|
+
* type DivRef = React.ElementRef<'div'>;
|
1517
|
+
* ```
|
1518
|
+
*/
|
1519
|
+
type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
1741
1520
|
: never;
|
1742
1521
|
|
1743
1522
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
@@ -1838,6 +1617,11 @@ declare namespace React {
|
|
1838
1617
|
* A {@link Dispatch} function can sometimes be called without any arguments.
|
1839
1618
|
*/
|
1840
1619
|
type DispatchWithoutAction = () => void;
|
1620
|
+
// Limit the reducer to accept only 0 or 1 action arguments
|
1621
|
+
// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
|
1622
|
+
type AnyActionArg = [] | [any];
|
1623
|
+
// Get the dispatch type from the reducer arguments (captures optional action argument correctly)
|
1624
|
+
type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
|
1841
1625
|
// Unlike redux, the actions _can_ be anything
|
1842
1626
|
type Reducer<S, A> = (prevState: S, action: A) => S;
|
1843
1627
|
// If useReducer accepts a reducer without action, dispatch may be called without any parameters.
|
@@ -1845,15 +1629,14 @@ declare namespace React {
|
|
1845
1629
|
// types used to try and prevent the compiler from reducing S
|
1846
1630
|
// to a supertype common with the second argument to useReducer()
|
1847
1631
|
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
1848
|
-
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
1849
|
-
// The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
|
1850
|
-
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
|
1851
|
-
: never;
|
1852
1632
|
type DependencyList = readonly unknown[];
|
1853
1633
|
|
1854
1634
|
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
1855
1635
|
type EffectCallback = () => void | Destructor;
|
1856
1636
|
|
1637
|
+
/**
|
1638
|
+
* @deprecated Use `RefObject` instead.
|
1639
|
+
*/
|
1857
1640
|
interface MutableRefObject<T> {
|
1858
1641
|
current: T;
|
1859
1642
|
}
|
@@ -1892,46 +1675,10 @@ declare namespace React {
|
|
1892
1675
|
* @version 16.8.0
|
1893
1676
|
* @see {@link https://react.dev/reference/react/useReducer}
|
1894
1677
|
*/
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
initializer: (arg: I) => ReducerStateWithoutAction<R>,
|
1900
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
1901
|
-
/**
|
1902
|
-
* An alternative to `useState`.
|
1903
|
-
*
|
1904
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1905
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1906
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
1907
|
-
*
|
1908
|
-
* @version 16.8.0
|
1909
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
1910
|
-
*/
|
1911
|
-
// overload where dispatch could accept 0 arguments.
|
1912
|
-
function useReducer<R extends ReducerWithoutAction<any>>(
|
1913
|
-
reducer: R,
|
1914
|
-
initializerArg: ReducerStateWithoutAction<R>,
|
1915
|
-
initializer?: undefined,
|
1916
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
1917
|
-
/**
|
1918
|
-
* An alternative to `useState`.
|
1919
|
-
*
|
1920
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1921
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1922
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
1923
|
-
*
|
1924
|
-
* @version 16.8.0
|
1925
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
1926
|
-
*/
|
1927
|
-
// overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
|
1928
|
-
// If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
|
1929
|
-
// the last overload effectively behaves as if the identity function (x => x) is the initializer.
|
1930
|
-
function useReducer<R extends Reducer<any, any>, I>(
|
1931
|
-
reducer: R,
|
1932
|
-
initializerArg: I & ReducerState<R>,
|
1933
|
-
initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
|
1934
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1678
|
+
function useReducer<S, A extends AnyActionArg>(
|
1679
|
+
reducer: (prevState: S, ...args: A) => S,
|
1680
|
+
initialState: S,
|
1681
|
+
): [S, ActionDispatch<A>];
|
1935
1682
|
/**
|
1936
1683
|
* An alternative to `useState`.
|
1937
1684
|
*
|
@@ -1942,12 +1689,10 @@ declare namespace React {
|
|
1942
1689
|
* @version 16.8.0
|
1943
1690
|
* @see {@link https://react.dev/reference/react/useReducer}
|
1944
1691
|
*/
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
initializer: (arg: I) => ReducerState<R>,
|
1950
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1692
|
+
function useReducer<S, A extends AnyActionArg>(
|
1693
|
+
reducer: (prevState: S, ...args: A) => S,
|
1694
|
+
initialState: S,
|
1695
|
+
): [S, ActionDispatch<A>];
|
1951
1696
|
/**
|
1952
1697
|
* An alternative to `useState`.
|
1953
1698
|
*
|
@@ -1958,21 +1703,11 @@ declare namespace React {
|
|
1958
1703
|
* @version 16.8.0
|
1959
1704
|
* @see {@link https://react.dev/reference/react/useReducer}
|
1960
1705
|
*/
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
// supertype between the reducer's return type and the initialState (or the initializer's return type),
|
1967
|
-
// which would prevent autocompletion from ever working.
|
1968
|
-
|
1969
|
-
// TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
|
1970
|
-
// in older versions, or a regression in newer versions of the typescript completion service.
|
1971
|
-
function useReducer<R extends Reducer<any, any>>(
|
1972
|
-
reducer: R,
|
1973
|
-
initialState: ReducerState<R>,
|
1974
|
-
initializer?: undefined,
|
1975
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1706
|
+
function useReducer<S, I, A extends AnyActionArg>(
|
1707
|
+
reducer: (prevState: S, ...args: A) => S,
|
1708
|
+
initialArg: I,
|
1709
|
+
init: (i: I) => S,
|
1710
|
+
): [S, ActionDispatch<A>];
|
1976
1711
|
/**
|
1977
1712
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
1978
1713
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
@@ -1983,7 +1718,7 @@ declare namespace React {
|
|
1983
1718
|
* @version 16.8.0
|
1984
1719
|
* @see {@link https://react.dev/reference/react/useRef}
|
1985
1720
|
*/
|
1986
|
-
function useRef<T>(initialValue: T):
|
1721
|
+
function useRef<T>(initialValue: T): RefObject<T>;
|
1987
1722
|
// convenience overload for refs given as a ref prop as they typically start with a null value
|
1988
1723
|
/**
|
1989
1724
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
@@ -1992,15 +1727,11 @@ declare namespace React {
|
|
1992
1727
|
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
1993
1728
|
* value around similar to how you’d use instance fields in classes.
|
1994
1729
|
*
|
1995
|
-
* Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
|
1996
|
-
* of the generic argument.
|
1997
|
-
*
|
1998
1730
|
* @version 16.8.0
|
1999
1731
|
* @see {@link https://react.dev/reference/react/useRef}
|
2000
1732
|
*/
|
2001
|
-
function useRef<T>(initialValue: T | null): RefObject<T>;
|
2002
|
-
// convenience overload for
|
2003
|
-
// has a default to stop it from defaulting to {} instead
|
1733
|
+
function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
1734
|
+
// convenience overload for undefined initialValue
|
2004
1735
|
/**
|
2005
1736
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
2006
1737
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
@@ -2011,7 +1742,7 @@ declare namespace React {
|
|
2011
1742
|
* @version 16.8.0
|
2012
1743
|
* @see {@link https://react.dev/reference/react/useRef}
|
2013
1744
|
*/
|
2014
|
-
function useRef<T
|
1745
|
+
function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
2015
1746
|
/**
|
2016
1747
|
* The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
|
2017
1748
|
* Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
|
@@ -2081,8 +1812,7 @@ declare namespace React {
|
|
2081
1812
|
// it's just the function name without the "use" prefix.
|
2082
1813
|
function useDebugValue<T>(value: T, format?: (value: T) => any): void;
|
2083
1814
|
|
2084
|
-
|
2085
|
-
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
1815
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
|
2086
1816
|
// strange definition to allow vscode to show documentation on the invocation
|
2087
1817
|
export interface TransitionStartFunction {
|
2088
1818
|
/**
|
@@ -2090,7 +1820,7 @@ declare namespace React {
|
|
2090
1820
|
*
|
2091
1821
|
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
2092
1822
|
*
|
2093
|
-
* @param callback A
|
1823
|
+
* @param callback A function which causes state updates that can be deferred.
|
2094
1824
|
*/
|
2095
1825
|
(callback: TransitionFunction): void;
|
2096
1826
|
}
|
@@ -2129,9 +1859,10 @@ declare namespace React {
|
|
2129
1859
|
/**
|
2130
1860
|
* Similar to `useTransition` but allows uses where hooks are not available.
|
2131
1861
|
*
|
2132
|
-
* @param callback A
|
1862
|
+
* @param callback A function which causes state updates that can be deferred.
|
2133
1863
|
*/
|
2134
1864
|
export function startTransition(scope: TransitionFunction): void;
|
1865
|
+
export function startTransition(scope: TransitionFunction): void;
|
2135
1866
|
|
2136
1867
|
/**
|
2137
1868
|
* Wrap any code rendering and triggering updates to your components into `act()` calls.
|
@@ -2144,6 +1875,11 @@ declare namespace React {
|
|
2144
1875
|
*
|
2145
1876
|
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
2146
1877
|
*/
|
1878
|
+
// NOTES
|
1879
|
+
// - the order of these signatures matters - typescript will check the signatures in source order.
|
1880
|
+
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
|
1881
|
+
// `strictNullChecks: false`.
|
1882
|
+
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
|
2147
1883
|
// 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.
|
2148
1884
|
export function act(callback: () => VoidOrUndefinedOnly): void;
|
2149
1885
|
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
|
@@ -2171,6 +1907,32 @@ declare namespace React {
|
|
2171
1907
|
getServerSnapshot?: () => Snapshot,
|
2172
1908
|
): Snapshot;
|
2173
1909
|
|
1910
|
+
export function useOptimistic<State>(
|
1911
|
+
passthrough: State,
|
1912
|
+
): [State, (action: State | ((pendingState: State) => State)) => void];
|
1913
|
+
export function useOptimistic<State, Action>(
|
1914
|
+
passthrough: State,
|
1915
|
+
reducer: (state: State, action: Action) => State,
|
1916
|
+
): [State, (action: Action) => void];
|
1917
|
+
|
1918
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
1919
|
+
|
1920
|
+
export function use<T>(usable: Usable<T>): T;
|
1921
|
+
|
1922
|
+
export function useActionState<State>(
|
1923
|
+
action: (state: Awaited<State>) => State | Promise<State>,
|
1924
|
+
initialState: Awaited<State>,
|
1925
|
+
permalink?: string,
|
1926
|
+
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
1927
|
+
export function useActionState<State, Payload>(
|
1928
|
+
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
1929
|
+
initialState: Awaited<State>,
|
1930
|
+
permalink?: string,
|
1931
|
+
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
1932
|
+
|
1933
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
1934
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
1935
|
+
|
2174
1936
|
//
|
2175
1937
|
// Event System
|
2176
1938
|
// ----------------------------------------------------------------------
|
@@ -2338,6 +2100,11 @@ declare namespace React {
|
|
2338
2100
|
pseudoElement: string;
|
2339
2101
|
}
|
2340
2102
|
|
2103
|
+
interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
|
2104
|
+
oldState: "closed" | "open";
|
2105
|
+
newState: "closed" | "open";
|
2106
|
+
}
|
2107
|
+
|
2341
2108
|
interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
|
2342
2109
|
elapsedTime: number;
|
2343
2110
|
propertyName: string;
|
@@ -2365,6 +2132,7 @@ declare namespace React {
|
|
2365
2132
|
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
2366
2133
|
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
|
2367
2134
|
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
|
2135
|
+
type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
|
2368
2136
|
type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
|
2369
2137
|
|
2370
2138
|
//
|
@@ -2578,9 +2346,19 @@ declare namespace React {
|
|
2578
2346
|
onAnimationIteration?: AnimationEventHandler<T> | undefined;
|
2579
2347
|
onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
|
2580
2348
|
|
2349
|
+
// Toggle Events
|
2350
|
+
onToggle?: ToggleEventHandler<T> | undefined;
|
2351
|
+
onBeforeToggle?: ToggleEventHandler<T> | undefined;
|
2352
|
+
|
2581
2353
|
// Transition Events
|
2354
|
+
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
2355
|
+
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
2582
2356
|
onTransitionEnd?: TransitionEventHandler<T> | undefined;
|
2583
2357
|
onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
|
2358
|
+
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
2359
|
+
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
2360
|
+
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
2361
|
+
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
2584
2362
|
}
|
2585
2363
|
|
2586
2364
|
export interface CSSProperties extends CSS.Properties<string | number> {
|
@@ -2951,7 +2729,16 @@ declare namespace React {
|
|
2951
2729
|
security?: string | undefined;
|
2952
2730
|
unselectable?: "on" | "off" | undefined;
|
2953
2731
|
|
2732
|
+
// Popover API
|
2733
|
+
popover?: "" | "auto" | "manual" | undefined;
|
2734
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
|
2735
|
+
popoverTarget?: string | undefined;
|
2736
|
+
|
2954
2737
|
// Living Standard
|
2738
|
+
/**
|
2739
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
2740
|
+
*/
|
2741
|
+
inert?: boolean | undefined;
|
2955
2742
|
/**
|
2956
2743
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
2957
2744
|
* @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
|
@@ -2978,6 +2765,7 @@ declare namespace React {
|
|
2978
2765
|
action?:
|
2979
2766
|
| string
|
2980
2767
|
| undefined
|
2768
|
+
| ((formData: FormData) => void | Promise<void>)
|
2981
2769
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
2982
2770
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
2983
2771
|
];
|
@@ -3012,6 +2800,7 @@ declare namespace React {
|
|
3012
2800
|
formAction?:
|
3013
2801
|
| string
|
3014
2802
|
| undefined
|
2803
|
+
| ((formData: FormData) => void | Promise<void>)
|
3015
2804
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3016
2805
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3017
2806
|
];
|
@@ -3144,6 +2933,7 @@ declare namespace React {
|
|
3144
2933
|
form?: string | undefined;
|
3145
2934
|
formAction?:
|
3146
2935
|
| string
|
2936
|
+
| ((formData: FormData) => void | Promise<void>)
|
3147
2937
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3148
2938
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3149
2939
|
]
|
@@ -3177,7 +2967,6 @@ declare namespace React {
|
|
3177
2967
|
|
3178
2968
|
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
3179
2969
|
open?: boolean | undefined;
|
3180
|
-
onToggle?: ReactEventHandler<T> | undefined;
|
3181
2970
|
name?: string | undefined;
|
3182
2971
|
}
|
3183
2972
|
|
@@ -3210,6 +2999,7 @@ declare namespace React {
|
|
3210
2999
|
action?:
|
3211
3000
|
| string
|
3212
3001
|
| undefined
|
3002
|
+
| ((formData: FormData) => void | Promise<void>)
|
3213
3003
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3214
3004
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3215
3005
|
];
|
@@ -3365,6 +3155,7 @@ declare namespace React {
|
|
3365
3155
|
form?: string | undefined;
|
3366
3156
|
formAction?:
|
3367
3157
|
| string
|
3158
|
+
| ((formData: FormData) => void | Promise<void>)
|
3368
3159
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3369
3160
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3370
3161
|
]
|
@@ -3427,6 +3218,9 @@ declare namespace React {
|
|
3427
3218
|
sizes?: string | undefined;
|
3428
3219
|
type?: string | undefined;
|
3429
3220
|
charSet?: string | undefined;
|
3221
|
+
|
3222
|
+
// React props
|
3223
|
+
precedence?: string | undefined;
|
3430
3224
|
}
|
3431
3225
|
|
3432
3226
|
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -3561,6 +3355,10 @@ declare namespace React {
|
|
3561
3355
|
media?: string | undefined;
|
3562
3356
|
scoped?: boolean | undefined;
|
3563
3357
|
type?: string | undefined;
|
3358
|
+
|
3359
|
+
// React props
|
3360
|
+
href?: string | undefined;
|
3361
|
+
precedence?: string | undefined;
|
3564
3362
|
}
|
3565
3363
|
|
3566
3364
|
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -3948,259 +3746,184 @@ declare namespace React {
|
|
3948
3746
|
webpreferences?: string | undefined;
|
3949
3747
|
}
|
3950
3748
|
|
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
|
-
|
4129
|
-
tspan: SVGFactory;
|
4130
|
-
use: SVGFactory;
|
4131
|
-
view: SVGFactory;
|
4132
|
-
}
|
4133
|
-
|
4134
|
-
interface ReactDOM extends ReactHTML, ReactSVG {}
|
4135
|
-
|
4136
|
-
//
|
4137
|
-
// React.PropTypes
|
4138
|
-
// ----------------------------------------------------------------------
|
4139
|
-
|
4140
|
-
/**
|
4141
|
-
* @deprecated Use `Validator` from the ´prop-types` instead.
|
4142
|
-
*/
|
4143
|
-
type Validator<T> = PropTypes.Validator<T>;
|
4144
|
-
|
4145
|
-
/**
|
4146
|
-
* @deprecated Use `Requireable` from the ´prop-types` instead.
|
4147
|
-
*/
|
4148
|
-
type Requireable<T> = PropTypes.Requireable<T>;
|
4149
|
-
|
4150
|
-
/**
|
4151
|
-
* @deprecated Use `ValidationMap` from the ´prop-types` instead.
|
4152
|
-
*/
|
4153
|
-
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
4154
|
-
|
4155
|
-
/**
|
4156
|
-
* @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
|
4157
|
-
*/
|
4158
|
-
type WeakValidationMap<T> = {
|
4159
|
-
[K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
|
4160
|
-
: undefined extends T[K] ? Validator<T[K] | null | undefined>
|
4161
|
-
: Validator<T[K]>;
|
4162
|
-
};
|
4163
|
-
|
4164
|
-
/**
|
4165
|
-
* @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
|
4166
|
-
*/
|
4167
|
-
interface ReactPropTypes {
|
4168
|
-
any: typeof PropTypes.any;
|
4169
|
-
array: typeof PropTypes.array;
|
4170
|
-
bool: typeof PropTypes.bool;
|
4171
|
-
func: typeof PropTypes.func;
|
4172
|
-
number: typeof PropTypes.number;
|
4173
|
-
object: typeof PropTypes.object;
|
4174
|
-
string: typeof PropTypes.string;
|
4175
|
-
node: typeof PropTypes.node;
|
4176
|
-
element: typeof PropTypes.element;
|
4177
|
-
instanceOf: typeof PropTypes.instanceOf;
|
4178
|
-
oneOf: typeof PropTypes.oneOf;
|
4179
|
-
oneOfType: typeof PropTypes.oneOfType;
|
4180
|
-
arrayOf: typeof PropTypes.arrayOf;
|
4181
|
-
objectOf: typeof PropTypes.objectOf;
|
4182
|
-
shape: typeof PropTypes.shape;
|
4183
|
-
exact: typeof PropTypes.exact;
|
4184
|
-
}
|
4185
|
-
|
4186
|
-
//
|
4187
|
-
// React.Children
|
4188
|
-
// ----------------------------------------------------------------------
|
4189
|
-
|
4190
|
-
/**
|
4191
|
-
* @deprecated - Use `typeof React.Children` instead.
|
4192
|
-
*/
|
4193
|
-
// Sync with type of `const Children`.
|
4194
|
-
interface ReactChildren {
|
4195
|
-
map<T, C>(
|
4196
|
-
children: C | readonly C[],
|
4197
|
-
fn: (child: C, index: number) => T,
|
4198
|
-
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
4199
|
-
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
4200
|
-
count(children: any): number;
|
4201
|
-
only<C>(children: C): C extends any[] ? never : C;
|
4202
|
-
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
4203
|
-
}
|
3749
|
+
// TODO: Move to react-dom
|
3750
|
+
type HTMLElementType =
|
3751
|
+
| "a"
|
3752
|
+
| "abbr"
|
3753
|
+
| "address"
|
3754
|
+
| "area"
|
3755
|
+
| "article"
|
3756
|
+
| "aside"
|
3757
|
+
| "audio"
|
3758
|
+
| "b"
|
3759
|
+
| "base"
|
3760
|
+
| "bdi"
|
3761
|
+
| "bdo"
|
3762
|
+
| "big"
|
3763
|
+
| "blockquote"
|
3764
|
+
| "body"
|
3765
|
+
| "br"
|
3766
|
+
| "button"
|
3767
|
+
| "canvas"
|
3768
|
+
| "caption"
|
3769
|
+
| "center"
|
3770
|
+
| "cite"
|
3771
|
+
| "code"
|
3772
|
+
| "col"
|
3773
|
+
| "colgroup"
|
3774
|
+
| "data"
|
3775
|
+
| "datalist"
|
3776
|
+
| "dd"
|
3777
|
+
| "del"
|
3778
|
+
| "details"
|
3779
|
+
| "dfn"
|
3780
|
+
| "dialog"
|
3781
|
+
| "div"
|
3782
|
+
| "dl"
|
3783
|
+
| "dt"
|
3784
|
+
| "em"
|
3785
|
+
| "embed"
|
3786
|
+
| "fieldset"
|
3787
|
+
| "figcaption"
|
3788
|
+
| "figure"
|
3789
|
+
| "footer"
|
3790
|
+
| "form"
|
3791
|
+
| "h1"
|
3792
|
+
| "h2"
|
3793
|
+
| "h3"
|
3794
|
+
| "h4"
|
3795
|
+
| "h5"
|
3796
|
+
| "h6"
|
3797
|
+
| "head"
|
3798
|
+
| "header"
|
3799
|
+
| "hgroup"
|
3800
|
+
| "hr"
|
3801
|
+
| "html"
|
3802
|
+
| "i"
|
3803
|
+
| "iframe"
|
3804
|
+
| "img"
|
3805
|
+
| "input"
|
3806
|
+
| "ins"
|
3807
|
+
| "kbd"
|
3808
|
+
| "keygen"
|
3809
|
+
| "label"
|
3810
|
+
| "legend"
|
3811
|
+
| "li"
|
3812
|
+
| "link"
|
3813
|
+
| "main"
|
3814
|
+
| "map"
|
3815
|
+
| "mark"
|
3816
|
+
| "menu"
|
3817
|
+
| "menuitem"
|
3818
|
+
| "meta"
|
3819
|
+
| "meter"
|
3820
|
+
| "nav"
|
3821
|
+
| "noscript"
|
3822
|
+
| "object"
|
3823
|
+
| "ol"
|
3824
|
+
| "optgroup"
|
3825
|
+
| "option"
|
3826
|
+
| "output"
|
3827
|
+
| "p"
|
3828
|
+
| "param"
|
3829
|
+
| "picture"
|
3830
|
+
| "pre"
|
3831
|
+
| "progress"
|
3832
|
+
| "q"
|
3833
|
+
| "rp"
|
3834
|
+
| "rt"
|
3835
|
+
| "ruby"
|
3836
|
+
| "s"
|
3837
|
+
| "samp"
|
3838
|
+
| "search"
|
3839
|
+
| "slot"
|
3840
|
+
| "script"
|
3841
|
+
| "section"
|
3842
|
+
| "select"
|
3843
|
+
| "small"
|
3844
|
+
| "source"
|
3845
|
+
| "span"
|
3846
|
+
| "strong"
|
3847
|
+
| "style"
|
3848
|
+
| "sub"
|
3849
|
+
| "summary"
|
3850
|
+
| "sup"
|
3851
|
+
| "table"
|
3852
|
+
| "template"
|
3853
|
+
| "tbody"
|
3854
|
+
| "td"
|
3855
|
+
| "textarea"
|
3856
|
+
| "tfoot"
|
3857
|
+
| "th"
|
3858
|
+
| "thead"
|
3859
|
+
| "time"
|
3860
|
+
| "title"
|
3861
|
+
| "tr"
|
3862
|
+
| "track"
|
3863
|
+
| "u"
|
3864
|
+
| "ul"
|
3865
|
+
| "var"
|
3866
|
+
| "video"
|
3867
|
+
| "wbr"
|
3868
|
+
| "webview";
|
3869
|
+
|
3870
|
+
// TODO: Move to react-dom
|
3871
|
+
type SVGElementType =
|
3872
|
+
| "animate"
|
3873
|
+
| "circle"
|
3874
|
+
| "clipPath"
|
3875
|
+
| "defs"
|
3876
|
+
| "desc"
|
3877
|
+
| "ellipse"
|
3878
|
+
| "feBlend"
|
3879
|
+
| "feColorMatrix"
|
3880
|
+
| "feComponentTransfer"
|
3881
|
+
| "feComposite"
|
3882
|
+
| "feConvolveMatrix"
|
3883
|
+
| "feDiffuseLighting"
|
3884
|
+
| "feDisplacementMap"
|
3885
|
+
| "feDistantLight"
|
3886
|
+
| "feDropShadow"
|
3887
|
+
| "feFlood"
|
3888
|
+
| "feFuncA"
|
3889
|
+
| "feFuncB"
|
3890
|
+
| "feFuncG"
|
3891
|
+
| "feFuncR"
|
3892
|
+
| "feGaussianBlur"
|
3893
|
+
| "feImage"
|
3894
|
+
| "feMerge"
|
3895
|
+
| "feMergeNode"
|
3896
|
+
| "feMorphology"
|
3897
|
+
| "feOffset"
|
3898
|
+
| "fePointLight"
|
3899
|
+
| "feSpecularLighting"
|
3900
|
+
| "feSpotLight"
|
3901
|
+
| "feTile"
|
3902
|
+
| "feTurbulence"
|
3903
|
+
| "filter"
|
3904
|
+
| "foreignObject"
|
3905
|
+
| "g"
|
3906
|
+
| "image"
|
3907
|
+
| "line"
|
3908
|
+
| "linearGradient"
|
3909
|
+
| "marker"
|
3910
|
+
| "mask"
|
3911
|
+
| "metadata"
|
3912
|
+
| "path"
|
3913
|
+
| "pattern"
|
3914
|
+
| "polygon"
|
3915
|
+
| "polyline"
|
3916
|
+
| "radialGradient"
|
3917
|
+
| "rect"
|
3918
|
+
| "stop"
|
3919
|
+
| "svg"
|
3920
|
+
| "switch"
|
3921
|
+
| "symbol"
|
3922
|
+
| "text"
|
3923
|
+
| "textPath"
|
3924
|
+
| "tspan"
|
3925
|
+
| "use"
|
3926
|
+
| "view";
|
4204
3927
|
|
4205
3928
|
//
|
4206
3929
|
// Browser Interfaces
|
@@ -4242,67 +3965,6 @@ declare namespace React {
|
|
4242
3965
|
}
|
4243
3966
|
|
4244
3967
|
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
4245
|
-
namespace JSX {
|
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
3968
|
namespace JSX {
|
4307
3969
|
interface Element extends React.ReactElement<any, any> {}
|
4308
3970
|
interface ElementClass extends React.Component<any> {
|
@@ -4514,17 +4176,18 @@ declare global {
|
|
4514
4176
|
}
|
4515
4177
|
}
|
4516
4178
|
|
4517
|
-
|
4518
|
-
// But we can't access global.JSX so we need to create these aliases instead.
|
4519
|
-
// Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
|
4520
|
-
interface GlobalJSXElement extends JSX.Element {}
|
4521
|
-
interface GlobalJSXElementClass extends JSX.ElementClass {}
|
4522
|
-
interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
|
4523
|
-
interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
|
4524
|
-
|
4525
|
-
type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
|
4179
|
+
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
4526
4180
|
|
4527
|
-
|
4528
|
-
|
4181
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
4182
|
+
// Undeclared default props are augmented into the resulting allowable attributes
|
4183
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
4184
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
4185
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
4186
|
+
:
|
4187
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
4188
|
+
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
4189
|
+
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
4190
|
+
: never;
|
4529
4191
|
|
4530
|
-
|
4192
|
+
type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
|
4193
|
+
: P;
|