@types/react 18.3.1 → 19.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- react/README.md +3 -3
- react/canary.d.ts +17 -120
- react/compiler-runtime.d.ts +4 -0
- react/experimental.d.ts +116 -15
- react/global.d.ts +6 -0
- react/index.d.ts +513 -785
- react/package.json +9 -9
- react/ts5.0/canary.d.ts +17 -120
- react/ts5.0/experimental.d.ts +116 -15
- react/ts5.0/global.d.ts +6 -0
- react/ts5.0/index.d.ts +510 -783
- react/ts5.0/v18/global.d.ts +161 -0
- react/ts5.0/v18/index.d.ts +4564 -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 +161 -0
- react/ts5.0/v18/ts5.0/index.d.ts +4551 -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,17 +5,18 @@
|
|
|
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;
|
|
12
11
|
type NativeCompositionEvent = CompositionEvent;
|
|
13
12
|
type NativeDragEvent = DragEvent;
|
|
14
13
|
type NativeFocusEvent = FocusEvent;
|
|
14
|
+
type NativeInputEvent = InputEvent;
|
|
15
15
|
type NativeKeyboardEvent = KeyboardEvent;
|
|
16
16
|
type NativeMouseEvent = MouseEvent;
|
|
17
17
|
type NativeTouchEvent = TouchEvent;
|
|
18
18
|
type NativePointerEvent = PointerEvent;
|
|
19
|
+
type NativeToggleEvent = ToggleEvent;
|
|
19
20
|
type NativeTransitionEvent = TransitionEvent;
|
|
20
21
|
type NativeUIEvent = UIEvent;
|
|
21
22
|
type NativeWheelEvent = WheelEvent;
|
|
@@ -33,6 +34,25 @@ type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
|
|
|
33
34
|
|
|
34
35
|
declare const UNDEFINED_VOID_ONLY: unique symbol;
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @internal Use `Awaited<ReactNode>` instead
|
|
39
|
+
*/
|
|
40
|
+
// Helper type to enable `Awaited<ReactNode>`.
|
|
41
|
+
// Must be a copy of the non-thenables of `ReactNode`.
|
|
42
|
+
type AwaitedReactNode =
|
|
43
|
+
| React.ReactElement
|
|
44
|
+
| string
|
|
45
|
+
| number
|
|
46
|
+
| bigint
|
|
47
|
+
| Iterable<React.ReactNode>
|
|
48
|
+
| React.ReactPortal
|
|
49
|
+
| boolean
|
|
50
|
+
| null
|
|
51
|
+
| undefined
|
|
52
|
+
| React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
|
53
|
+
keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
|
54
|
+
];
|
|
55
|
+
|
|
36
56
|
/**
|
|
37
57
|
* The function returned from an effect passed to {@link React.useEffect useEffect},
|
|
38
58
|
* which can be used to clean up the effect when the component unmounts.
|
|
@@ -93,8 +113,7 @@ declare namespace React {
|
|
|
93
113
|
* Represents any user-defined component, either as a function or a class.
|
|
94
114
|
*
|
|
95
115
|
* Similar to {@link JSXElementConstructor}, but with extra properties like
|
|
96
|
-
* {@link FunctionComponent.defaultProps defaultProps }
|
|
97
|
-
* {@link ComponentClass.contextTypes contextTypes}.
|
|
116
|
+
* {@link FunctionComponent.defaultProps defaultProps }.
|
|
98
117
|
*
|
|
99
118
|
* @template P The props the component accepts.
|
|
100
119
|
*
|
|
@@ -107,34 +126,18 @@ declare namespace React {
|
|
|
107
126
|
* Represents any user-defined component, either as a function or a class.
|
|
108
127
|
*
|
|
109
128
|
* Similar to {@link ComponentType}, but without extra properties like
|
|
110
|
-
* {@link FunctionComponent.defaultProps defaultProps }
|
|
111
|
-
* {@link ComponentClass.contextTypes contextTypes}.
|
|
129
|
+
* {@link FunctionComponent.defaultProps defaultProps }.
|
|
112
130
|
*
|
|
113
131
|
* @template P The props the component accepts.
|
|
114
132
|
*/
|
|
115
133
|
type JSXElementConstructor<P> =
|
|
116
134
|
| ((
|
|
117
135
|
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
136
|
) => 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>);
|
|
137
|
+
// constructor signature must match React.Component
|
|
138
|
+
| (new(props: P, context: any) => Component<any, any>);
|
|
134
139
|
|
|
135
140
|
/**
|
|
136
|
-
* A readonly ref container where {@link current} cannot be mutated.
|
|
137
|
-
*
|
|
138
141
|
* Created by {@link createRef}, or {@link useRef} when passed `null`.
|
|
139
142
|
*
|
|
140
143
|
* @template T The type of the ref's value.
|
|
@@ -151,7 +154,7 @@ declare namespace React {
|
|
|
151
154
|
/**
|
|
152
155
|
* The current value of the ref.
|
|
153
156
|
*/
|
|
154
|
-
|
|
157
|
+
current: T;
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
|
|
@@ -174,6 +177,7 @@ declare namespace React {
|
|
|
174
177
|
instance: T | null,
|
|
175
178
|
):
|
|
176
179
|
| void
|
|
180
|
+
| (() => VoidOrUndefinedOnly)
|
|
177
181
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[
|
|
178
182
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES
|
|
179
183
|
];
|
|
@@ -186,22 +190,15 @@ declare namespace React {
|
|
|
186
190
|
* @see {@link RefObject}
|
|
187
191
|
*/
|
|
188
192
|
|
|
189
|
-
type Ref<T> = RefCallback<T> | RefObject<T> | null;
|
|
193
|
+
type Ref<T> = RefCallback<T> | RefObject<T | null> | null;
|
|
190
194
|
/**
|
|
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
|
-
* ```
|
|
195
|
+
* @deprecated Use `Ref` instead. String refs are no longer supported.
|
|
196
|
+
* If you're typing a library with support for React versions with string refs, use `RefAttributes<T>['ref']` instead.
|
|
200
197
|
*/
|
|
201
|
-
|
|
202
|
-
type LegacyRef<T> = string | Ref<T>;
|
|
203
|
-
|
|
198
|
+
type LegacyRef<T> = Ref<T>;
|
|
204
199
|
/**
|
|
200
|
+
* @deprecated Use `ComponentRef<T>` instead
|
|
201
|
+
*
|
|
205
202
|
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
|
206
203
|
*
|
|
207
204
|
* @template C The component type.
|
|
@@ -221,18 +218,10 @@ declare namespace React {
|
|
|
221
218
|
type ElementRef<
|
|
222
219
|
C extends
|
|
223
220
|
| ForwardRefExoticComponent<any>
|
|
224
|
-
| { new(props: any): Component<any> }
|
|
225
|
-
| ((props: any
|
|
221
|
+
| { new(props: any, context: any): Component<any> }
|
|
222
|
+
| ((props: any) => ReactElement | null)
|
|
226
223
|
| 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;
|
|
224
|
+
> = ComponentRef<C>;
|
|
236
225
|
|
|
237
226
|
type ComponentState = any;
|
|
238
227
|
|
|
@@ -300,7 +289,7 @@ declare namespace React {
|
|
|
300
289
|
*
|
|
301
290
|
* @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
|
|
302
291
|
*/
|
|
303
|
-
ref?:
|
|
292
|
+
ref?: Ref<T> | undefined;
|
|
304
293
|
}
|
|
305
294
|
|
|
306
295
|
/**
|
|
@@ -325,7 +314,7 @@ declare namespace React {
|
|
|
325
314
|
* ```
|
|
326
315
|
*/
|
|
327
316
|
interface ReactElement<
|
|
328
|
-
P =
|
|
317
|
+
P = unknown,
|
|
329
318
|
T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
|
|
330
319
|
> {
|
|
331
320
|
type: T;
|
|
@@ -341,13 +330,28 @@ declare namespace React {
|
|
|
341
330
|
P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
|
|
342
331
|
> extends ReactElement<P, Exclude<T, number>> {}
|
|
343
332
|
|
|
333
|
+
/**
|
|
334
|
+
* @deprecated Use `ReactElement<P, React.FunctionComponent<P>>`
|
|
335
|
+
*/
|
|
344
336
|
interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
|
|
337
|
+
/**
|
|
338
|
+
* @deprecated Use `element.props.ref` instead.
|
|
339
|
+
*/
|
|
345
340
|
ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
|
|
346
341
|
}
|
|
347
342
|
|
|
343
|
+
/**
|
|
344
|
+
* @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
|
|
345
|
+
*/
|
|
348
346
|
type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
|
|
347
|
+
/**
|
|
348
|
+
* @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
|
|
349
|
+
*/
|
|
349
350
|
interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
|
|
350
|
-
|
|
351
|
+
/**
|
|
352
|
+
* @deprecated Use `element.props.ref` instead.
|
|
353
|
+
*/
|
|
354
|
+
ref?: Ref<T> | undefined;
|
|
351
355
|
}
|
|
352
356
|
|
|
353
357
|
/**
|
|
@@ -356,89 +360,34 @@ declare namespace React {
|
|
|
356
360
|
type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
|
|
357
361
|
|
|
358
362
|
// string fallback for custom web-components
|
|
363
|
+
/**
|
|
364
|
+
* @deprecated Use `ReactElement<P, string>`
|
|
365
|
+
*/
|
|
359
366
|
interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
|
|
360
367
|
extends ReactElement<P, string>
|
|
361
368
|
{
|
|
362
|
-
|
|
369
|
+
/**
|
|
370
|
+
* @deprecated Use `element.props.ref` instead.
|
|
371
|
+
*/
|
|
372
|
+
ref: Ref<T>;
|
|
363
373
|
}
|
|
364
374
|
|
|
365
375
|
// ReactHTML for ReactHTMLElement
|
|
366
376
|
interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
|
|
367
377
|
|
|
368
378
|
interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
|
|
369
|
-
type:
|
|
379
|
+
type: HTMLElementType;
|
|
370
380
|
}
|
|
371
381
|
|
|
372
382
|
// ReactSVG for ReactSVGElement
|
|
373
383
|
interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
|
|
374
|
-
type:
|
|
384
|
+
type: SVGElementType;
|
|
375
385
|
}
|
|
376
386
|
|
|
377
387
|
interface ReactPortal extends ReactElement {
|
|
378
388
|
children: ReactNode;
|
|
379
389
|
}
|
|
380
390
|
|
|
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
391
|
/**
|
|
443
392
|
* For internal usage only.
|
|
444
393
|
* Different release channels declare additional types of ReactNode this particular release channel accepts.
|
|
@@ -480,6 +429,7 @@ declare namespace React {
|
|
|
480
429
|
| ReactElement
|
|
481
430
|
| string
|
|
482
431
|
| number
|
|
432
|
+
| bigint
|
|
483
433
|
| Iterable<ReactNode>
|
|
484
434
|
| ReactPortal
|
|
485
435
|
| boolean
|
|
@@ -487,36 +437,13 @@ declare namespace React {
|
|
|
487
437
|
| undefined
|
|
488
438
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
|
489
439
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
|
490
|
-
]
|
|
440
|
+
]
|
|
441
|
+
| Promise<AwaitedReactNode>;
|
|
491
442
|
|
|
492
443
|
//
|
|
493
444
|
// Top Level API
|
|
494
445
|
// ----------------------------------------------------------------------
|
|
495
446
|
|
|
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
447
|
// DOM Elements
|
|
521
448
|
// TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
|
|
522
449
|
function createElement(
|
|
@@ -525,12 +452,12 @@ declare namespace React {
|
|
|
525
452
|
...children: ReactNode[]
|
|
526
453
|
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
527
454
|
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
|
528
|
-
type:
|
|
455
|
+
type: HTMLElementType,
|
|
529
456
|
props?: ClassAttributes<T> & P | null,
|
|
530
457
|
...children: ReactNode[]
|
|
531
458
|
): DetailedReactHTMLElement<P, T>;
|
|
532
459
|
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
|
533
|
-
type:
|
|
460
|
+
type: SVGElementType,
|
|
534
461
|
props?: ClassAttributes<T> & P | null,
|
|
535
462
|
...children: ReactNode[]
|
|
536
463
|
): ReactSVGElement;
|
|
@@ -659,7 +586,6 @@ declare namespace React {
|
|
|
659
586
|
* @template P The props the component accepts.
|
|
660
587
|
*/
|
|
661
588
|
interface ProviderExoticComponent<P> extends ExoticComponent<P> {
|
|
662
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
663
589
|
}
|
|
664
590
|
|
|
665
591
|
/**
|
|
@@ -741,7 +667,7 @@ declare namespace React {
|
|
|
741
667
|
* const ThemeContext = createContext('light');
|
|
742
668
|
* ```
|
|
743
669
|
*/
|
|
744
|
-
interface Context<T> {
|
|
670
|
+
interface Context<T> extends Provider<T> {
|
|
745
671
|
Provider: Provider<T>;
|
|
746
672
|
Consumer: Consumer<T>;
|
|
747
673
|
/**
|
|
@@ -770,6 +696,13 @@ declare namespace React {
|
|
|
770
696
|
* import { createContext } from 'react';
|
|
771
697
|
*
|
|
772
698
|
* const ThemeContext = createContext('light');
|
|
699
|
+
* function App() {
|
|
700
|
+
* return (
|
|
701
|
+
* <ThemeContext value="dark">
|
|
702
|
+
* <Toolbar />
|
|
703
|
+
* </ThemeContext>
|
|
704
|
+
* );
|
|
705
|
+
* }
|
|
773
706
|
* ```
|
|
774
707
|
*/
|
|
775
708
|
function createContext<T>(
|
|
@@ -780,9 +713,6 @@ declare namespace React {
|
|
|
780
713
|
|
|
781
714
|
function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
|
|
782
715
|
|
|
783
|
-
/**
|
|
784
|
-
* Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
|
|
785
|
-
*/
|
|
786
716
|
const Children: {
|
|
787
717
|
map<T, C>(
|
|
788
718
|
children: C | readonly C[],
|
|
@@ -793,6 +723,10 @@ declare namespace React {
|
|
|
793
723
|
only<C>(children: C): C extends any[] ? never : C;
|
|
794
724
|
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
|
795
725
|
};
|
|
726
|
+
|
|
727
|
+
export interface FragmentProps {
|
|
728
|
+
children?: React.ReactNode;
|
|
729
|
+
}
|
|
796
730
|
/**
|
|
797
731
|
* Lets you group elements without a wrapper node.
|
|
798
732
|
*
|
|
@@ -820,7 +754,7 @@ declare namespace React {
|
|
|
820
754
|
* </>
|
|
821
755
|
* ```
|
|
822
756
|
*/
|
|
823
|
-
const Fragment: ExoticComponent<
|
|
757
|
+
const Fragment: ExoticComponent<FragmentProps>;
|
|
824
758
|
|
|
825
759
|
/**
|
|
826
760
|
* Lets you find common bugs in your components early during development.
|
|
@@ -849,6 +783,12 @@ declare namespace React {
|
|
|
849
783
|
|
|
850
784
|
/** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
|
|
851
785
|
fallback?: ReactNode;
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* A name for this Suspense boundary for instrumentation purposes.
|
|
789
|
+
* The name will help identify this boundary in React DevTools.
|
|
790
|
+
*/
|
|
791
|
+
name?: string | undefined;
|
|
852
792
|
}
|
|
853
793
|
|
|
854
794
|
/**
|
|
@@ -983,7 +923,13 @@ declare namespace React {
|
|
|
983
923
|
static contextType?: Context<any> | undefined;
|
|
984
924
|
|
|
985
925
|
/**
|
|
986
|
-
*
|
|
926
|
+
* Ignored by React.
|
|
927
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
928
|
+
*/
|
|
929
|
+
static propTypes?: any;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* If using React Context, re-declare this in your class to be the
|
|
987
933
|
* `React.ContextType` of your `static contextType`.
|
|
988
934
|
* Should be used with type annotation or static contextType.
|
|
989
935
|
*
|
|
@@ -1000,11 +946,15 @@ declare namespace React {
|
|
|
1000
946
|
*/
|
|
1001
947
|
context: unknown;
|
|
1002
948
|
|
|
949
|
+
// Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
|
|
1003
950
|
constructor(props: P);
|
|
1004
951
|
/**
|
|
1005
|
-
* @
|
|
1006
|
-
* @
|
|
952
|
+
* @param props
|
|
953
|
+
* @param context value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
|
|
954
|
+
* in `contextType`.
|
|
1007
955
|
*/
|
|
956
|
+
// TODO: Ideally we'd infer the constructor signatur from `contextType`.
|
|
957
|
+
// Might be hard to ship without breaking existing code.
|
|
1008
958
|
constructor(props: P, context: any);
|
|
1009
959
|
|
|
1010
960
|
// We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
|
|
@@ -1020,14 +970,6 @@ declare namespace React {
|
|
|
1020
970
|
|
|
1021
971
|
readonly props: Readonly<P>;
|
|
1022
972
|
state: Readonly<S>;
|
|
1023
|
-
/**
|
|
1024
|
-
* @deprecated
|
|
1025
|
-
*
|
|
1026
|
-
* @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
|
|
1027
|
-
*/
|
|
1028
|
-
refs: {
|
|
1029
|
-
[key: string]: ReactInstance;
|
|
1030
|
-
};
|
|
1031
973
|
}
|
|
1032
974
|
|
|
1033
975
|
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
|
|
@@ -1044,10 +986,6 @@ declare namespace React {
|
|
|
1044
986
|
getInitialState?(): S;
|
|
1045
987
|
}
|
|
1046
988
|
|
|
1047
|
-
interface ChildContextProvider<CC> {
|
|
1048
|
-
getChildContext(): CC;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
989
|
//
|
|
1052
990
|
// Class Interfaces
|
|
1053
991
|
// ----------------------------------------------------------------------
|
|
@@ -1112,58 +1050,12 @@ declare namespace React {
|
|
|
1112
1050
|
* ```
|
|
1113
1051
|
*/
|
|
1114
1052
|
interface FunctionComponent<P = {}> {
|
|
1115
|
-
(
|
|
1116
|
-
props: P,
|
|
1117
|
-
/**
|
|
1118
|
-
* @deprecated
|
|
1119
|
-
*
|
|
1120
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
|
1121
|
-
*/
|
|
1122
|
-
deprecatedLegacyContext?: any,
|
|
1123
|
-
): ReactElement<any, any> | null;
|
|
1053
|
+
(props: P): ReactElement<any, any> | null;
|
|
1124
1054
|
/**
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
* and in development only.
|
|
1128
|
-
*
|
|
1129
|
-
* We recommend using TypeScript instead of checking prop
|
|
1130
|
-
* types at runtime.
|
|
1131
|
-
*
|
|
1132
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
|
1055
|
+
* Ignored by React.
|
|
1056
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1133
1057
|
*/
|
|
1134
|
-
propTypes?:
|
|
1135
|
-
/**
|
|
1136
|
-
* @deprecated
|
|
1137
|
-
*
|
|
1138
|
-
* Lets you specify which legacy context is consumed by
|
|
1139
|
-
* this component.
|
|
1140
|
-
*
|
|
1141
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
|
1142
|
-
*/
|
|
1143
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1144
|
-
/**
|
|
1145
|
-
* Used to define default values for the props accepted by
|
|
1146
|
-
* the component.
|
|
1147
|
-
*
|
|
1148
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
|
1149
|
-
*
|
|
1150
|
-
* @example
|
|
1151
|
-
*
|
|
1152
|
-
* ```tsx
|
|
1153
|
-
* type Props = { name?: string }
|
|
1154
|
-
*
|
|
1155
|
-
* const MyComponent: FC<Props> = (props) => {
|
|
1156
|
-
* return <div>{props.name}</div>
|
|
1157
|
-
* }
|
|
1158
|
-
*
|
|
1159
|
-
* MyComponent.defaultProps = {
|
|
1160
|
-
* name: 'John Doe'
|
|
1161
|
-
* }
|
|
1162
|
-
* ```
|
|
1163
|
-
*
|
|
1164
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
|
1165
|
-
*/
|
|
1166
|
-
defaultProps?: Partial<P> | undefined;
|
|
1058
|
+
propTypes?: any;
|
|
1167
1059
|
/**
|
|
1168
1060
|
* Used in debugging messages. You might want to set it
|
|
1169
1061
|
* explicitly if you want to display a different name for
|
|
@@ -1185,38 +1077,6 @@ declare namespace React {
|
|
|
1185
1077
|
displayName?: string | undefined;
|
|
1186
1078
|
}
|
|
1187
1079
|
|
|
1188
|
-
/**
|
|
1189
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
|
1190
|
-
*
|
|
1191
|
-
* @see {@link React.FunctionComponent}
|
|
1192
|
-
* @alias {@link VoidFunctionComponent}
|
|
1193
|
-
*/
|
|
1194
|
-
type VFC<P = {}> = VoidFunctionComponent<P>;
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
|
1198
|
-
*
|
|
1199
|
-
* @see {@link React.FunctionComponent}
|
|
1200
|
-
*/
|
|
1201
|
-
interface VoidFunctionComponent<P = {}> {
|
|
1202
|
-
(
|
|
1203
|
-
props: P,
|
|
1204
|
-
/**
|
|
1205
|
-
* @deprecated
|
|
1206
|
-
*
|
|
1207
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
|
1208
|
-
*/
|
|
1209
|
-
deprecatedLegacyContext?: any,
|
|
1210
|
-
): ReactElement<any, any> | null;
|
|
1211
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
1212
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1213
|
-
/**
|
|
1214
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
|
1215
|
-
*/
|
|
1216
|
-
defaultProps?: Partial<P> | undefined;
|
|
1217
|
-
displayName?: string | undefined;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
1080
|
/**
|
|
1221
1081
|
* The type of the ref received by a {@link ForwardRefRenderFunction}.
|
|
1222
1082
|
*
|
|
@@ -1251,19 +1111,10 @@ declare namespace React {
|
|
|
1251
1111
|
*/
|
|
1252
1112
|
displayName?: string | undefined;
|
|
1253
1113
|
/**
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
|
1257
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
|
1258
|
-
*/
|
|
1259
|
-
defaultProps?: never | undefined;
|
|
1260
|
-
/**
|
|
1261
|
-
* propTypes are not supported on render functions passed to forwardRef.
|
|
1262
|
-
*
|
|
1263
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
|
1264
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
|
1114
|
+
* Ignored by React.
|
|
1115
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1265
1116
|
*/
|
|
1266
|
-
propTypes?:
|
|
1117
|
+
propTypes?: any;
|
|
1267
1118
|
}
|
|
1268
1119
|
|
|
1269
1120
|
/**
|
|
@@ -1273,48 +1124,20 @@ declare namespace React {
|
|
|
1273
1124
|
* @template S The internal state of the component.
|
|
1274
1125
|
*/
|
|
1275
1126
|
interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
|
|
1127
|
+
// constructor signature must match React.Component
|
|
1276
1128
|
new(
|
|
1277
|
-
props: P,
|
|
1278
|
-
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
|
1129
|
+
props: P, /**
|
|
1130
|
+
* Value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
|
|
1131
|
+
* in `contextType`.
|
|
1282
1132
|
*/
|
|
1283
|
-
|
|
1133
|
+
context?: any,
|
|
1284
1134
|
): Component<P, S>;
|
|
1285
1135
|
/**
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
* and in development only.
|
|
1289
|
-
*
|
|
1290
|
-
* We recommend using TypeScript instead of checking prop
|
|
1291
|
-
* types at runtime.
|
|
1292
|
-
*
|
|
1293
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
|
1136
|
+
* Ignored by React.
|
|
1137
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1294
1138
|
*/
|
|
1295
|
-
propTypes?:
|
|
1139
|
+
propTypes?: any;
|
|
1296
1140
|
contextType?: Context<any> | undefined;
|
|
1297
|
-
/**
|
|
1298
|
-
* @deprecated use {@link ComponentClass.contextType} instead
|
|
1299
|
-
*
|
|
1300
|
-
* Lets you specify which legacy context is consumed by
|
|
1301
|
-
* this component.
|
|
1302
|
-
*
|
|
1303
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
|
1304
|
-
*/
|
|
1305
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1306
|
-
/**
|
|
1307
|
-
* @deprecated
|
|
1308
|
-
*
|
|
1309
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
|
|
1310
|
-
*/
|
|
1311
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
|
1312
|
-
/**
|
|
1313
|
-
* Used to define default values for the props accepted by
|
|
1314
|
-
* the component.
|
|
1315
|
-
*
|
|
1316
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
|
1317
|
-
*/
|
|
1318
1141
|
defaultProps?: Partial<P> | undefined;
|
|
1319
1142
|
/**
|
|
1320
1143
|
* Used in debugging messages. You might want to set it
|
|
@@ -1333,7 +1156,7 @@ declare namespace React {
|
|
|
1333
1156
|
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
|
1334
1157
|
*/
|
|
1335
1158
|
interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
|
|
1336
|
-
new(props: P
|
|
1159
|
+
new(props: P): ClassicComponent<P, ComponentState>;
|
|
1337
1160
|
getDefaultProps?(): P;
|
|
1338
1161
|
}
|
|
1339
1162
|
|
|
@@ -1348,7 +1171,7 @@ declare namespace React {
|
|
|
1348
1171
|
*/
|
|
1349
1172
|
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
|
1350
1173
|
& C
|
|
1351
|
-
& (new(props: P,
|
|
1174
|
+
& (new(props: P, context: any) => T);
|
|
1352
1175
|
|
|
1353
1176
|
//
|
|
1354
1177
|
// Component Specs and Lifecycle
|
|
@@ -1522,38 +1345,7 @@ declare namespace React {
|
|
|
1522
1345
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
|
|
1523
1346
|
}
|
|
1524
1347
|
|
|
1525
|
-
|
|
1526
|
-
* @deprecated
|
|
1527
|
-
*
|
|
1528
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
|
1529
|
-
*/
|
|
1530
|
-
interface Mixin<P, S> extends ComponentLifecycle<P, S> {
|
|
1531
|
-
mixins?: Array<Mixin<P, S>> | undefined;
|
|
1532
|
-
statics?: {
|
|
1533
|
-
[key: string]: any;
|
|
1534
|
-
} | undefined;
|
|
1535
|
-
|
|
1536
|
-
displayName?: string | undefined;
|
|
1537
|
-
propTypes?: ValidationMap<any> | undefined;
|
|
1538
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1539
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
|
1540
|
-
|
|
1541
|
-
getDefaultProps?(): P;
|
|
1542
|
-
getInitialState?(): S;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
/**
|
|
1546
|
-
* @deprecated
|
|
1547
|
-
*
|
|
1548
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
|
1549
|
-
*/
|
|
1550
|
-
interface ComponentSpec<P, S> extends Mixin<P, S> {
|
|
1551
|
-
render(): ReactNode;
|
|
1552
|
-
|
|
1553
|
-
[propertyName: string]: any;
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
function createRef<T>(): RefObject<T>;
|
|
1348
|
+
function createRef<T>(): RefObject<T | null>;
|
|
1557
1349
|
|
|
1558
1350
|
/**
|
|
1559
1351
|
* The type of the component returned from {@link forwardRef}.
|
|
@@ -1564,10 +1356,10 @@ declare namespace React {
|
|
|
1564
1356
|
*/
|
|
1565
1357
|
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
|
1566
1358
|
/**
|
|
1567
|
-
*
|
|
1359
|
+
* Ignored by React.
|
|
1360
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1568
1361
|
*/
|
|
1569
|
-
|
|
1570
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
1362
|
+
propTypes?: any;
|
|
1571
1363
|
}
|
|
1572
1364
|
|
|
1573
1365
|
/**
|
|
@@ -1598,29 +1390,24 @@ declare namespace React {
|
|
|
1598
1390
|
* ```
|
|
1599
1391
|
*/
|
|
1600
1392
|
function forwardRef<T, P = {}>(
|
|
1601
|
-
render: ForwardRefRenderFunction<T, P
|
|
1393
|
+
render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
|
|
1602
1394
|
): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
1603
1395
|
|
|
1604
1396
|
/**
|
|
1605
1397
|
* Omits the 'ref' attribute from the given props object.
|
|
1606
1398
|
*
|
|
1607
|
-
* @template
|
|
1399
|
+
* @template Props The props object type.
|
|
1608
1400
|
*/
|
|
1609
|
-
type PropsWithoutRef<
|
|
1401
|
+
type PropsWithoutRef<Props> =
|
|
1610
1402
|
// Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
|
|
1611
1403
|
// see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
|
1612
1404
|
// https://github.com/Microsoft/TypeScript/issues/28339
|
|
1613
|
-
|
|
1614
|
-
/**
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
? P extends { ref?: infer R | undefined }
|
|
1620
|
-
? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
|
1621
|
-
: P
|
|
1622
|
-
: P
|
|
1623
|
-
: P;
|
|
1405
|
+
Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
|
|
1406
|
+
/**
|
|
1407
|
+
* Ensures that the props do not include string ref, which cannot be forwarded
|
|
1408
|
+
* @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
|
|
1409
|
+
*/
|
|
1410
|
+
type PropsWithRef<Props> = Props;
|
|
1624
1411
|
|
|
1625
1412
|
type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
|
|
1626
1413
|
|
|
@@ -1652,7 +1439,7 @@ declare namespace React {
|
|
|
1652
1439
|
* ```
|
|
1653
1440
|
*/
|
|
1654
1441
|
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
|
1655
|
-
JSXElementConstructor<infer
|
|
1442
|
+
JSXElementConstructor<infer Props> ? Props
|
|
1656
1443
|
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
|
1657
1444
|
: {};
|
|
1658
1445
|
|
|
@@ -1679,9 +1466,11 @@ declare namespace React {
|
|
|
1679
1466
|
* type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
|
|
1680
1467
|
* ```
|
|
1681
1468
|
*/
|
|
1682
|
-
type ComponentPropsWithRef<T extends ElementType> = T extends
|
|
1683
|
-
|
|
1684
|
-
:
|
|
1469
|
+
type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
|
|
1470
|
+
// If it's a class i.e. newable we're dealing with a class component
|
|
1471
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
|
1472
|
+
: Props
|
|
1473
|
+
: ComponentProps<T>;
|
|
1685
1474
|
/**
|
|
1686
1475
|
* Used to retrieve the props a custom component accepts with its ref.
|
|
1687
1476
|
*
|
|
@@ -1698,9 +1487,10 @@ declare namespace React {
|
|
|
1698
1487
|
* type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
|
|
1699
1488
|
* ```
|
|
1700
1489
|
*/
|
|
1701
|
-
type CustomComponentPropsWithRef<T extends ComponentType> = T extends
|
|
1702
|
-
|
|
1703
|
-
|
|
1490
|
+
type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
|
|
1491
|
+
// If it's a class i.e. newable we're dealing with a class component
|
|
1492
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
|
1493
|
+
: Props
|
|
1704
1494
|
: never;
|
|
1705
1495
|
|
|
1706
1496
|
/**
|
|
@@ -1728,10 +1518,24 @@ declare namespace React {
|
|
|
1728
1518
|
*/
|
|
1729
1519
|
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
|
1730
1520
|
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1521
|
+
/**
|
|
1522
|
+
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
|
1523
|
+
*
|
|
1524
|
+
* @template C The component type.
|
|
1525
|
+
*
|
|
1526
|
+
* @example
|
|
1527
|
+
*
|
|
1528
|
+
* ```tsx
|
|
1529
|
+
* type MyComponentRef = React.ComponentRef<typeof MyComponent>;
|
|
1530
|
+
* ```
|
|
1531
|
+
*
|
|
1532
|
+
* @example
|
|
1533
|
+
*
|
|
1534
|
+
* ```tsx
|
|
1535
|
+
* type DivRef = React.ComponentRef<'div'>;
|
|
1536
|
+
* ```
|
|
1537
|
+
*/
|
|
1538
|
+
type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
|
1735
1539
|
: never;
|
|
1736
1540
|
|
|
1737
1541
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
|
@@ -1832,6 +1636,11 @@ declare namespace React {
|
|
|
1832
1636
|
* A {@link Dispatch} function can sometimes be called without any arguments.
|
|
1833
1637
|
*/
|
|
1834
1638
|
type DispatchWithoutAction = () => void;
|
|
1639
|
+
// Limit the reducer to accept only 0 or 1 action arguments
|
|
1640
|
+
// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
|
|
1641
|
+
type AnyActionArg = [] | [any];
|
|
1642
|
+
// Get the dispatch type from the reducer arguments (captures optional action argument correctly)
|
|
1643
|
+
type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
|
|
1835
1644
|
// Unlike redux, the actions _can_ be anything
|
|
1836
1645
|
type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
1837
1646
|
// If useReducer accepts a reducer without action, dispatch may be called without any parameters.
|
|
@@ -1839,15 +1648,14 @@ declare namespace React {
|
|
|
1839
1648
|
// types used to try and prevent the compiler from reducing S
|
|
1840
1649
|
// to a supertype common with the second argument to useReducer()
|
|
1841
1650
|
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
|
1842
|
-
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
|
1843
|
-
// The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
|
|
1844
|
-
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
|
|
1845
|
-
: never;
|
|
1846
1651
|
type DependencyList = readonly unknown[];
|
|
1847
1652
|
|
|
1848
1653
|
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
|
1849
1654
|
type EffectCallback = () => void | Destructor;
|
|
1850
1655
|
|
|
1656
|
+
/**
|
|
1657
|
+
* @deprecated Use `RefObject` instead.
|
|
1658
|
+
*/
|
|
1851
1659
|
interface MutableRefObject<T> {
|
|
1852
1660
|
current: T;
|
|
1853
1661
|
}
|
|
@@ -1886,12 +1694,10 @@ declare namespace React {
|
|
|
1886
1694
|
* @version 16.8.0
|
|
1887
1695
|
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1888
1696
|
*/
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
initializer: (arg: I) => ReducerStateWithoutAction<R>,
|
|
1894
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
|
1697
|
+
function useReducer<S, A extends AnyActionArg>(
|
|
1698
|
+
reducer: (prevState: S, ...args: A) => S,
|
|
1699
|
+
initialState: S,
|
|
1700
|
+
): [S, ActionDispatch<A>];
|
|
1895
1701
|
/**
|
|
1896
1702
|
* An alternative to `useState`.
|
|
1897
1703
|
*
|
|
@@ -1902,71 +1708,11 @@ declare namespace React {
|
|
|
1902
1708
|
* @version 16.8.0
|
|
1903
1709
|
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1904
1710
|
*/
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
|
1911
|
-
/**
|
|
1912
|
-
* An alternative to `useState`.
|
|
1913
|
-
*
|
|
1914
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1915
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1916
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1917
|
-
*
|
|
1918
|
-
* @version 16.8.0
|
|
1919
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1920
|
-
*/
|
|
1921
|
-
// overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
|
|
1922
|
-
// If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
|
|
1923
|
-
// the last overload effectively behaves as if the identity function (x => x) is the initializer.
|
|
1924
|
-
function useReducer<R extends Reducer<any, any>, I>(
|
|
1925
|
-
reducer: R,
|
|
1926
|
-
initializerArg: I & ReducerState<R>,
|
|
1927
|
-
initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
|
|
1928
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
|
1929
|
-
/**
|
|
1930
|
-
* An alternative to `useState`.
|
|
1931
|
-
*
|
|
1932
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1933
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1934
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1935
|
-
*
|
|
1936
|
-
* @version 16.8.0
|
|
1937
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1938
|
-
*/
|
|
1939
|
-
// overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
|
|
1940
|
-
function useReducer<R extends Reducer<any, any>, I>(
|
|
1941
|
-
reducer: R,
|
|
1942
|
-
initializerArg: I,
|
|
1943
|
-
initializer: (arg: I) => ReducerState<R>,
|
|
1944
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
|
1945
|
-
/**
|
|
1946
|
-
* An alternative to `useState`.
|
|
1947
|
-
*
|
|
1948
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1949
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1950
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1951
|
-
*
|
|
1952
|
-
* @version 16.8.0
|
|
1953
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1954
|
-
*/
|
|
1955
|
-
|
|
1956
|
-
// I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.
|
|
1957
|
-
// The Flow types do have an overload for 3-ary invocation with undefined initializer.
|
|
1958
|
-
|
|
1959
|
-
// NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common
|
|
1960
|
-
// supertype between the reducer's return type and the initialState (or the initializer's return type),
|
|
1961
|
-
// which would prevent autocompletion from ever working.
|
|
1962
|
-
|
|
1963
|
-
// TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
|
|
1964
|
-
// in older versions, or a regression in newer versions of the typescript completion service.
|
|
1965
|
-
function useReducer<R extends Reducer<any, any>>(
|
|
1966
|
-
reducer: R,
|
|
1967
|
-
initialState: ReducerState<R>,
|
|
1968
|
-
initializer?: undefined,
|
|
1969
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
|
1711
|
+
function useReducer<S, I, A extends AnyActionArg>(
|
|
1712
|
+
reducer: (prevState: S, ...args: A) => S,
|
|
1713
|
+
initialArg: I,
|
|
1714
|
+
init: (i: I) => S,
|
|
1715
|
+
): [S, ActionDispatch<A>];
|
|
1970
1716
|
/**
|
|
1971
1717
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
1972
1718
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
|
@@ -1977,7 +1723,7 @@ declare namespace React {
|
|
|
1977
1723
|
* @version 16.8.0
|
|
1978
1724
|
* @see {@link https://react.dev/reference/react/useRef}
|
|
1979
1725
|
*/
|
|
1980
|
-
function useRef<T>(initialValue: T):
|
|
1726
|
+
function useRef<T>(initialValue: T): RefObject<T>;
|
|
1981
1727
|
// convenience overload for refs given as a ref prop as they typically start with a null value
|
|
1982
1728
|
/**
|
|
1983
1729
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
@@ -1986,15 +1732,11 @@ declare namespace React {
|
|
|
1986
1732
|
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
|
1987
1733
|
* value around similar to how you’d use instance fields in classes.
|
|
1988
1734
|
*
|
|
1989
|
-
* Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
|
|
1990
|
-
* of the generic argument.
|
|
1991
|
-
*
|
|
1992
1735
|
* @version 16.8.0
|
|
1993
1736
|
* @see {@link https://react.dev/reference/react/useRef}
|
|
1994
1737
|
*/
|
|
1995
|
-
function useRef<T>(initialValue: T | null): RefObject<T>;
|
|
1996
|
-
// convenience overload for
|
|
1997
|
-
// has a default to stop it from defaulting to {} instead
|
|
1738
|
+
function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
1739
|
+
// convenience overload for undefined initialValue
|
|
1998
1740
|
/**
|
|
1999
1741
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
2000
1742
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
|
@@ -2005,7 +1747,7 @@ declare namespace React {
|
|
|
2005
1747
|
* @version 16.8.0
|
|
2006
1748
|
* @see {@link https://react.dev/reference/react/useRef}
|
|
2007
1749
|
*/
|
|
2008
|
-
function useRef<T
|
|
1750
|
+
function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
|
2009
1751
|
/**
|
|
2010
1752
|
* The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
|
|
2011
1753
|
* Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
|
|
@@ -2035,8 +1777,6 @@ declare namespace React {
|
|
|
2035
1777
|
* `useImperativeHandle` customizes the instance value that is exposed to parent components when using
|
|
2036
1778
|
* `ref`. As always, imperative code using refs should be avoided in most cases.
|
|
2037
1779
|
*
|
|
2038
|
-
* `useImperativeHandle` should be used with `React.forwardRef`.
|
|
2039
|
-
*
|
|
2040
1780
|
* @version 16.8.0
|
|
2041
1781
|
* @see {@link https://react.dev/reference/react/useImperativeHandle}
|
|
2042
1782
|
*/
|
|
@@ -2052,7 +1792,7 @@ declare namespace React {
|
|
|
2052
1792
|
*/
|
|
2053
1793
|
// A specific function type would not trigger implicit any.
|
|
2054
1794
|
// See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
|
|
2055
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
1795
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2056
1796
|
function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
|
|
2057
1797
|
/**
|
|
2058
1798
|
* `useMemo` will only recompute the memoized value when one of the `deps` has changed.
|
|
@@ -2075,8 +1815,7 @@ declare namespace React {
|
|
|
2075
1815
|
// it's just the function name without the "use" prefix.
|
|
2076
1816
|
function useDebugValue<T>(value: T, format?: (value: T) => any): void;
|
|
2077
1817
|
|
|
2078
|
-
|
|
2079
|
-
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
|
1818
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
|
|
2080
1819
|
// strange definition to allow vscode to show documentation on the invocation
|
|
2081
1820
|
export interface TransitionStartFunction {
|
|
2082
1821
|
/**
|
|
@@ -2084,7 +1823,7 @@ declare namespace React {
|
|
|
2084
1823
|
*
|
|
2085
1824
|
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
|
2086
1825
|
*
|
|
2087
|
-
* @param callback A
|
|
1826
|
+
* @param callback A function which causes state updates that can be deferred.
|
|
2088
1827
|
*/
|
|
2089
1828
|
(callback: TransitionFunction): void;
|
|
2090
1829
|
}
|
|
@@ -2098,10 +1837,11 @@ declare namespace React {
|
|
|
2098
1837
|
* A good example of this is a text input.
|
|
2099
1838
|
*
|
|
2100
1839
|
* @param value The value that is going to be deferred
|
|
1840
|
+
* @param initialValue A value to use during the initial render of a component. If this option is omitted, `useDeferredValue` will not defer during the initial render, because there’s no previous version of `value` that it can render instead.
|
|
2101
1841
|
*
|
|
2102
1842
|
* @see {@link https://react.dev/reference/react/useDeferredValue}
|
|
2103
1843
|
*/
|
|
2104
|
-
export function useDeferredValue<T>(value: T): T;
|
|
1844
|
+
export function useDeferredValue<T>(value: T, initialValue?: T): T;
|
|
2105
1845
|
|
|
2106
1846
|
/**
|
|
2107
1847
|
* Allows components to avoid undesirable loading states by waiting for content to load
|
|
@@ -2123,7 +1863,7 @@ declare namespace React {
|
|
|
2123
1863
|
/**
|
|
2124
1864
|
* Similar to `useTransition` but allows uses where hooks are not available.
|
|
2125
1865
|
*
|
|
2126
|
-
* @param callback A
|
|
1866
|
+
* @param callback A function which causes state updates that can be deferred.
|
|
2127
1867
|
*/
|
|
2128
1868
|
export function startTransition(scope: TransitionFunction): void;
|
|
2129
1869
|
|
|
@@ -2138,6 +1878,11 @@ declare namespace React {
|
|
|
2138
1878
|
*
|
|
2139
1879
|
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
|
2140
1880
|
*/
|
|
1881
|
+
// NOTES
|
|
1882
|
+
// - the order of these signatures matters - typescript will check the signatures in source order.
|
|
1883
|
+
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
|
|
1884
|
+
// `strictNullChecks: false`.
|
|
1885
|
+
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
|
|
2141
1886
|
// 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.
|
|
2142
1887
|
export function act(callback: () => VoidOrUndefinedOnly): void;
|
|
2143
1888
|
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
@@ -2165,6 +1910,39 @@ declare namespace React {
|
|
|
2165
1910
|
getServerSnapshot?: () => Snapshot,
|
|
2166
1911
|
): Snapshot;
|
|
2167
1912
|
|
|
1913
|
+
export function useOptimistic<State>(
|
|
1914
|
+
passthrough: State,
|
|
1915
|
+
): [State, (action: State | ((pendingState: State) => State)) => void];
|
|
1916
|
+
export function useOptimistic<State, Action>(
|
|
1917
|
+
passthrough: State,
|
|
1918
|
+
reducer: (state: State, action: Action) => State,
|
|
1919
|
+
): [State, (action: Action) => void];
|
|
1920
|
+
|
|
1921
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
|
1922
|
+
|
|
1923
|
+
export function use<T>(usable: Usable<T>): T;
|
|
1924
|
+
|
|
1925
|
+
export function useActionState<State>(
|
|
1926
|
+
action: (state: Awaited<State>) => State | Promise<State>,
|
|
1927
|
+
initialState: Awaited<State>,
|
|
1928
|
+
permalink?: string,
|
|
1929
|
+
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
|
1930
|
+
export function useActionState<State, Payload>(
|
|
1931
|
+
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
|
1932
|
+
initialState: Awaited<State>,
|
|
1933
|
+
permalink?: string,
|
|
1934
|
+
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
1935
|
+
|
|
1936
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
1937
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
|
1938
|
+
|
|
1939
|
+
/**
|
|
1940
|
+
* Warning: Only available in development builds.
|
|
1941
|
+
*
|
|
1942
|
+
* @see {@link https://react.dev/reference/react/captureOwnerStack Reference docs}
|
|
1943
|
+
*/
|
|
1944
|
+
function captureOwnerStack(): string | null;
|
|
1945
|
+
|
|
2168
1946
|
//
|
|
2169
1947
|
// Event System
|
|
2170
1948
|
// ----------------------------------------------------------------------
|
|
@@ -2237,6 +2015,10 @@ declare namespace React {
|
|
|
2237
2015
|
target: EventTarget & T;
|
|
2238
2016
|
}
|
|
2239
2017
|
|
|
2018
|
+
interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
|
|
2019
|
+
data: string;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2240
2022
|
export type ModifierKey =
|
|
2241
2023
|
| "Alt"
|
|
2242
2024
|
| "AltGraph"
|
|
@@ -2332,6 +2114,11 @@ declare namespace React {
|
|
|
2332
2114
|
pseudoElement: string;
|
|
2333
2115
|
}
|
|
2334
2116
|
|
|
2117
|
+
interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
|
|
2118
|
+
oldState: "closed" | "open";
|
|
2119
|
+
newState: "closed" | "open";
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2335
2122
|
interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
|
|
2336
2123
|
elapsedTime: number;
|
|
2337
2124
|
propertyName: string;
|
|
@@ -2352,6 +2139,7 @@ declare namespace React {
|
|
|
2352
2139
|
type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
|
|
2353
2140
|
type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
|
|
2354
2141
|
type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
|
|
2142
|
+
type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
|
|
2355
2143
|
type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
|
|
2356
2144
|
type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
|
|
2357
2145
|
type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
|
|
@@ -2359,6 +2147,7 @@ declare namespace React {
|
|
|
2359
2147
|
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
|
2360
2148
|
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
|
|
2361
2149
|
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
|
|
2150
|
+
type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
|
|
2362
2151
|
type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
|
|
2363
2152
|
|
|
2364
2153
|
//
|
|
@@ -2409,7 +2198,7 @@ declare namespace React {
|
|
|
2409
2198
|
// Form Events
|
|
2410
2199
|
onChange?: FormEventHandler<T> | undefined;
|
|
2411
2200
|
onChangeCapture?: FormEventHandler<T> | undefined;
|
|
2412
|
-
onBeforeInput?:
|
|
2201
|
+
onBeforeInput?: InputEventHandler<T> | undefined;
|
|
2413
2202
|
onBeforeInputCapture?: FormEventHandler<T> | undefined;
|
|
2414
2203
|
onInput?: FormEventHandler<T> | undefined;
|
|
2415
2204
|
onInputCapture?: FormEventHandler<T> | undefined;
|
|
@@ -2429,9 +2218,9 @@ declare namespace React {
|
|
|
2429
2218
|
// Keyboard Events
|
|
2430
2219
|
onKeyDown?: KeyboardEventHandler<T> | undefined;
|
|
2431
2220
|
onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
|
|
2432
|
-
/** @deprecated */
|
|
2221
|
+
/** @deprecated Use `onKeyUp` or `onKeyDown` instead */
|
|
2433
2222
|
onKeyPress?: KeyboardEventHandler<T> | undefined;
|
|
2434
|
-
/** @deprecated */
|
|
2223
|
+
/** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
|
|
2435
2224
|
onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
|
|
2436
2225
|
onKeyUp?: KeyboardEventHandler<T> | undefined;
|
|
2437
2226
|
onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
|
|
@@ -2467,8 +2256,6 @@ declare namespace React {
|
|
|
2467
2256
|
onProgressCapture?: ReactEventHandler<T> | undefined;
|
|
2468
2257
|
onRateChange?: ReactEventHandler<T> | undefined;
|
|
2469
2258
|
onRateChangeCapture?: ReactEventHandler<T> | undefined;
|
|
2470
|
-
onResize?: ReactEventHandler<T> | undefined;
|
|
2471
|
-
onResizeCapture?: ReactEventHandler<T> | undefined;
|
|
2472
2259
|
onSeeked?: ReactEventHandler<T> | undefined;
|
|
2473
2260
|
onSeekedCapture?: ReactEventHandler<T> | undefined;
|
|
2474
2261
|
onSeeking?: ReactEventHandler<T> | undefined;
|
|
@@ -2559,6 +2346,8 @@ declare namespace React {
|
|
|
2559
2346
|
// UI Events
|
|
2560
2347
|
onScroll?: UIEventHandler<T> | undefined;
|
|
2561
2348
|
onScrollCapture?: UIEventHandler<T> | undefined;
|
|
2349
|
+
onScrollEnd?: UIEventHandler<T> | undefined;
|
|
2350
|
+
onScrollEndCapture?: UIEventHandler<T> | undefined;
|
|
2562
2351
|
|
|
2563
2352
|
// Wheel Events
|
|
2564
2353
|
onWheel?: WheelEventHandler<T> | undefined;
|
|
@@ -2572,9 +2361,19 @@ declare namespace React {
|
|
|
2572
2361
|
onAnimationIteration?: AnimationEventHandler<T> | undefined;
|
|
2573
2362
|
onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
|
|
2574
2363
|
|
|
2364
|
+
// Toggle Events
|
|
2365
|
+
onToggle?: ToggleEventHandler<T> | undefined;
|
|
2366
|
+
onBeforeToggle?: ToggleEventHandler<T> | undefined;
|
|
2367
|
+
|
|
2575
2368
|
// Transition Events
|
|
2369
|
+
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
|
2370
|
+
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
|
2576
2371
|
onTransitionEnd?: TransitionEventHandler<T> | undefined;
|
|
2577
2372
|
onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
|
|
2373
|
+
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
|
2374
|
+
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
|
2375
|
+
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
|
2376
|
+
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
|
2578
2377
|
}
|
|
2579
2378
|
|
|
2580
2379
|
export interface CSSProperties extends CSS.Properties<string | number> {
|
|
@@ -2894,12 +2693,14 @@ declare namespace React {
|
|
|
2894
2693
|
|
|
2895
2694
|
// Standard HTML Attributes
|
|
2896
2695
|
accessKey?: string | undefined;
|
|
2696
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
|
|
2897
2697
|
autoFocus?: boolean | undefined;
|
|
2898
2698
|
className?: string | undefined;
|
|
2899
2699
|
contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
|
|
2900
2700
|
contextMenu?: string | undefined;
|
|
2901
2701
|
dir?: string | undefined;
|
|
2902
2702
|
draggable?: Booleanish | undefined;
|
|
2703
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
2903
2704
|
hidden?: boolean | undefined;
|
|
2904
2705
|
id?: string | undefined;
|
|
2905
2706
|
lang?: string | undefined;
|
|
@@ -2931,7 +2732,6 @@ declare namespace React {
|
|
|
2931
2732
|
vocab?: string | undefined;
|
|
2932
2733
|
|
|
2933
2734
|
// Non-standard Attributes
|
|
2934
|
-
autoCapitalize?: string | undefined;
|
|
2935
2735
|
autoCorrect?: string | undefined;
|
|
2936
2736
|
autoSave?: string | undefined;
|
|
2937
2737
|
color?: string | undefined;
|
|
@@ -2944,7 +2744,16 @@ declare namespace React {
|
|
|
2944
2744
|
security?: string | undefined;
|
|
2945
2745
|
unselectable?: "on" | "off" | undefined;
|
|
2946
2746
|
|
|
2747
|
+
// Popover API
|
|
2748
|
+
popover?: "" | "auto" | "manual" | undefined;
|
|
2749
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
|
|
2750
|
+
popoverTarget?: string | undefined;
|
|
2751
|
+
|
|
2947
2752
|
// Living Standard
|
|
2753
|
+
/**
|
|
2754
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
|
2755
|
+
*/
|
|
2756
|
+
inert?: boolean | undefined;
|
|
2948
2757
|
/**
|
|
2949
2758
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
|
2950
2759
|
* @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
|
|
@@ -2955,6 +2764,14 @@ declare namespace React {
|
|
|
2955
2764
|
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
|
|
2956
2765
|
*/
|
|
2957
2766
|
is?: string | undefined;
|
|
2767
|
+
/**
|
|
2768
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
|
|
2769
|
+
*/
|
|
2770
|
+
exportparts?: string | undefined;
|
|
2771
|
+
/**
|
|
2772
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
|
|
2773
|
+
*/
|
|
2774
|
+
part?: string | undefined;
|
|
2958
2775
|
}
|
|
2959
2776
|
|
|
2960
2777
|
/**
|
|
@@ -2971,6 +2788,7 @@ declare namespace React {
|
|
|
2971
2788
|
action?:
|
|
2972
2789
|
| string
|
|
2973
2790
|
| undefined
|
|
2791
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
2974
2792
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
2975
2793
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
2976
2794
|
];
|
|
@@ -3005,6 +2823,7 @@ declare namespace React {
|
|
|
3005
2823
|
formAction?:
|
|
3006
2824
|
| string
|
|
3007
2825
|
| undefined
|
|
2826
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3008
2827
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3009
2828
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3010
2829
|
];
|
|
@@ -3137,6 +2956,7 @@ declare namespace React {
|
|
|
3137
2956
|
form?: string | undefined;
|
|
3138
2957
|
formAction?:
|
|
3139
2958
|
| string
|
|
2959
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3140
2960
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3141
2961
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3142
2962
|
]
|
|
@@ -3170,7 +2990,6 @@ declare namespace React {
|
|
|
3170
2990
|
|
|
3171
2991
|
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3172
2992
|
open?: boolean | undefined;
|
|
3173
|
-
onToggle?: ReactEventHandler<T> | undefined;
|
|
3174
2993
|
name?: string | undefined;
|
|
3175
2994
|
}
|
|
3176
2995
|
|
|
@@ -3203,6 +3022,7 @@ declare namespace React {
|
|
|
3203
3022
|
action?:
|
|
3204
3023
|
| string
|
|
3205
3024
|
| undefined
|
|
3025
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3206
3026
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3207
3027
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3208
3028
|
];
|
|
@@ -3241,6 +3061,8 @@ declare namespace React {
|
|
|
3241
3061
|
width?: number | string | undefined;
|
|
3242
3062
|
}
|
|
3243
3063
|
|
|
3064
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {}
|
|
3065
|
+
|
|
3244
3066
|
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3245
3067
|
alt?: string | undefined;
|
|
3246
3068
|
crossOrigin?: CrossOrigin;
|
|
@@ -3250,7 +3072,12 @@ declare namespace React {
|
|
|
3250
3072
|
loading?: "eager" | "lazy" | undefined;
|
|
3251
3073
|
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
3252
3074
|
sizes?: string | undefined;
|
|
3253
|
-
src?:
|
|
3075
|
+
src?:
|
|
3076
|
+
| string
|
|
3077
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES[
|
|
3078
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES
|
|
3079
|
+
]
|
|
3080
|
+
| undefined;
|
|
3254
3081
|
srcSet?: string | undefined;
|
|
3255
3082
|
useMap?: string | undefined;
|
|
3256
3083
|
width?: number | string | undefined;
|
|
@@ -3355,10 +3182,10 @@ declare namespace React {
|
|
|
3355
3182
|
capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
|
|
3356
3183
|
checked?: boolean | undefined;
|
|
3357
3184
|
disabled?: boolean | undefined;
|
|
3358
|
-
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
3359
3185
|
form?: string | undefined;
|
|
3360
3186
|
formAction?:
|
|
3361
3187
|
| string
|
|
3188
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3362
3189
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3363
3190
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3364
3191
|
]
|
|
@@ -3409,6 +3236,7 @@ declare namespace React {
|
|
|
3409
3236
|
|
|
3410
3237
|
interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3411
3238
|
as?: string | undefined;
|
|
3239
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3412
3240
|
crossOrigin?: CrossOrigin;
|
|
3413
3241
|
fetchPriority?: "high" | "low" | "auto";
|
|
3414
3242
|
href?: string | undefined;
|
|
@@ -3421,6 +3249,9 @@ declare namespace React {
|
|
|
3421
3249
|
sizes?: string | undefined;
|
|
3422
3250
|
type?: string | undefined;
|
|
3423
3251
|
charSet?: string | undefined;
|
|
3252
|
+
|
|
3253
|
+
// React props
|
|
3254
|
+
precedence?: string | undefined;
|
|
3424
3255
|
}
|
|
3425
3256
|
|
|
3426
3257
|
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3431,6 +3262,8 @@ declare namespace React {
|
|
|
3431
3262
|
type?: string | undefined;
|
|
3432
3263
|
}
|
|
3433
3264
|
|
|
3265
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {}
|
|
3266
|
+
|
|
3434
3267
|
interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3435
3268
|
autoPlay?: boolean | undefined;
|
|
3436
3269
|
controls?: boolean | undefined;
|
|
@@ -3441,7 +3274,12 @@ declare namespace React {
|
|
|
3441
3274
|
muted?: boolean | undefined;
|
|
3442
3275
|
playsInline?: boolean | undefined;
|
|
3443
3276
|
preload?: string | undefined;
|
|
3444
|
-
src?:
|
|
3277
|
+
src?:
|
|
3278
|
+
| string
|
|
3279
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES[
|
|
3280
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES
|
|
3281
|
+
]
|
|
3282
|
+
| undefined;
|
|
3445
3283
|
}
|
|
3446
3284
|
|
|
3447
3285
|
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3518,10 +3356,12 @@ declare namespace React {
|
|
|
3518
3356
|
|
|
3519
3357
|
interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3520
3358
|
async?: boolean | undefined;
|
|
3359
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3521
3360
|
/** @deprecated */
|
|
3522
3361
|
charSet?: string | undefined;
|
|
3523
3362
|
crossOrigin?: CrossOrigin;
|
|
3524
3363
|
defer?: boolean | undefined;
|
|
3364
|
+
fetchPriority?: "high" | "low" | "auto" | undefined;
|
|
3525
3365
|
integrity?: string | undefined;
|
|
3526
3366
|
noModule?: boolean | undefined;
|
|
3527
3367
|
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
@@ -3552,9 +3392,14 @@ declare namespace React {
|
|
|
3552
3392
|
}
|
|
3553
3393
|
|
|
3554
3394
|
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3395
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3555
3396
|
media?: string | undefined;
|
|
3556
3397
|
scoped?: boolean | undefined;
|
|
3557
3398
|
type?: string | undefined;
|
|
3399
|
+
|
|
3400
|
+
// React props
|
|
3401
|
+
href?: string | undefined;
|
|
3402
|
+
precedence?: string | undefined;
|
|
3558
3403
|
}
|
|
3559
3404
|
|
|
3560
3405
|
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3628,6 +3473,9 @@ declare namespace React {
|
|
|
3628
3473
|
width?: number | string | undefined;
|
|
3629
3474
|
disablePictureInPicture?: boolean | undefined;
|
|
3630
3475
|
disableRemotePlayback?: boolean | undefined;
|
|
3476
|
+
|
|
3477
|
+
onResize?: ReactEventHandler<T> | undefined;
|
|
3478
|
+
onResizeCapture?: ReactEventHandler<T> | undefined;
|
|
3631
3479
|
}
|
|
3632
3480
|
|
|
3633
3481
|
// this list is "complete" in that it contains every SVG attribute
|
|
@@ -3721,7 +3569,21 @@ declare namespace React {
|
|
|
3721
3569
|
direction?: number | string | undefined;
|
|
3722
3570
|
display?: number | string | undefined;
|
|
3723
3571
|
divisor?: number | string | undefined;
|
|
3724
|
-
dominantBaseline?:
|
|
3572
|
+
dominantBaseline?:
|
|
3573
|
+
| "auto"
|
|
3574
|
+
| "use-script"
|
|
3575
|
+
| "no-change"
|
|
3576
|
+
| "reset-size"
|
|
3577
|
+
| "ideographic"
|
|
3578
|
+
| "alphabetic"
|
|
3579
|
+
| "hanging"
|
|
3580
|
+
| "mathematical"
|
|
3581
|
+
| "central"
|
|
3582
|
+
| "middle"
|
|
3583
|
+
| "text-after-edge"
|
|
3584
|
+
| "text-before-edge"
|
|
3585
|
+
| "inherit"
|
|
3586
|
+
| undefined;
|
|
3725
3587
|
dur?: number | string | undefined;
|
|
3726
3588
|
dx?: number | string | undefined;
|
|
3727
3589
|
dy?: number | string | undefined;
|
|
@@ -3868,7 +3730,7 @@ declare namespace React {
|
|
|
3868
3730
|
tableValues?: number | string | undefined;
|
|
3869
3731
|
targetX?: number | string | undefined;
|
|
3870
3732
|
targetY?: number | string | undefined;
|
|
3871
|
-
textAnchor?:
|
|
3733
|
+
textAnchor?: "start" | "middle" | "end" | "inherit" | undefined;
|
|
3872
3734
|
textDecoration?: number | string | undefined;
|
|
3873
3735
|
textLength?: number | string | undefined;
|
|
3874
3736
|
textRendering?: number | string | undefined;
|
|
@@ -3942,259 +3804,184 @@ declare namespace React {
|
|
|
3942
3804
|
webpreferences?: string | undefined;
|
|
3943
3805
|
}
|
|
3944
3806
|
|
|
3945
|
-
//
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
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
|
-
tspan: SVGFactory;
|
|
4124
|
-
use: SVGFactory;
|
|
4125
|
-
view: SVGFactory;
|
|
4126
|
-
}
|
|
4127
|
-
|
|
4128
|
-
interface ReactDOM extends ReactHTML, ReactSVG {}
|
|
4129
|
-
|
|
4130
|
-
//
|
|
4131
|
-
// React.PropTypes
|
|
4132
|
-
// ----------------------------------------------------------------------
|
|
4133
|
-
|
|
4134
|
-
/**
|
|
4135
|
-
* @deprecated Use `Validator` from the ´prop-types` instead.
|
|
4136
|
-
*/
|
|
4137
|
-
type Validator<T> = PropTypes.Validator<T>;
|
|
4138
|
-
|
|
4139
|
-
/**
|
|
4140
|
-
* @deprecated Use `Requireable` from the ´prop-types` instead.
|
|
4141
|
-
*/
|
|
4142
|
-
type Requireable<T> = PropTypes.Requireable<T>;
|
|
4143
|
-
|
|
4144
|
-
/**
|
|
4145
|
-
* @deprecated Use `ValidationMap` from the ´prop-types` instead.
|
|
4146
|
-
*/
|
|
4147
|
-
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
|
4148
|
-
|
|
4149
|
-
/**
|
|
4150
|
-
* @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
|
|
4151
|
-
*/
|
|
4152
|
-
type WeakValidationMap<T> = {
|
|
4153
|
-
[K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
|
|
4154
|
-
: undefined extends T[K] ? Validator<T[K] | null | undefined>
|
|
4155
|
-
: Validator<T[K]>;
|
|
4156
|
-
};
|
|
4157
|
-
|
|
4158
|
-
/**
|
|
4159
|
-
* @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
|
|
4160
|
-
*/
|
|
4161
|
-
interface ReactPropTypes {
|
|
4162
|
-
any: typeof PropTypes.any;
|
|
4163
|
-
array: typeof PropTypes.array;
|
|
4164
|
-
bool: typeof PropTypes.bool;
|
|
4165
|
-
func: typeof PropTypes.func;
|
|
4166
|
-
number: typeof PropTypes.number;
|
|
4167
|
-
object: typeof PropTypes.object;
|
|
4168
|
-
string: typeof PropTypes.string;
|
|
4169
|
-
node: typeof PropTypes.node;
|
|
4170
|
-
element: typeof PropTypes.element;
|
|
4171
|
-
instanceOf: typeof PropTypes.instanceOf;
|
|
4172
|
-
oneOf: typeof PropTypes.oneOf;
|
|
4173
|
-
oneOfType: typeof PropTypes.oneOfType;
|
|
4174
|
-
arrayOf: typeof PropTypes.arrayOf;
|
|
4175
|
-
objectOf: typeof PropTypes.objectOf;
|
|
4176
|
-
shape: typeof PropTypes.shape;
|
|
4177
|
-
exact: typeof PropTypes.exact;
|
|
4178
|
-
}
|
|
4179
|
-
|
|
4180
|
-
//
|
|
4181
|
-
// React.Children
|
|
4182
|
-
// ----------------------------------------------------------------------
|
|
4183
|
-
|
|
4184
|
-
/**
|
|
4185
|
-
* @deprecated - Use `typeof React.Children` instead.
|
|
4186
|
-
*/
|
|
4187
|
-
// Sync with type of `const Children`.
|
|
4188
|
-
interface ReactChildren {
|
|
4189
|
-
map<T, C>(
|
|
4190
|
-
children: C | readonly C[],
|
|
4191
|
-
fn: (child: C, index: number) => T,
|
|
4192
|
-
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
|
4193
|
-
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
|
4194
|
-
count(children: any): number;
|
|
4195
|
-
only<C>(children: C): C extends any[] ? never : C;
|
|
4196
|
-
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
|
4197
|
-
}
|
|
3807
|
+
// TODO: Move to react-dom
|
|
3808
|
+
type HTMLElementType =
|
|
3809
|
+
| "a"
|
|
3810
|
+
| "abbr"
|
|
3811
|
+
| "address"
|
|
3812
|
+
| "area"
|
|
3813
|
+
| "article"
|
|
3814
|
+
| "aside"
|
|
3815
|
+
| "audio"
|
|
3816
|
+
| "b"
|
|
3817
|
+
| "base"
|
|
3818
|
+
| "bdi"
|
|
3819
|
+
| "bdo"
|
|
3820
|
+
| "big"
|
|
3821
|
+
| "blockquote"
|
|
3822
|
+
| "body"
|
|
3823
|
+
| "br"
|
|
3824
|
+
| "button"
|
|
3825
|
+
| "canvas"
|
|
3826
|
+
| "caption"
|
|
3827
|
+
| "center"
|
|
3828
|
+
| "cite"
|
|
3829
|
+
| "code"
|
|
3830
|
+
| "col"
|
|
3831
|
+
| "colgroup"
|
|
3832
|
+
| "data"
|
|
3833
|
+
| "datalist"
|
|
3834
|
+
| "dd"
|
|
3835
|
+
| "del"
|
|
3836
|
+
| "details"
|
|
3837
|
+
| "dfn"
|
|
3838
|
+
| "dialog"
|
|
3839
|
+
| "div"
|
|
3840
|
+
| "dl"
|
|
3841
|
+
| "dt"
|
|
3842
|
+
| "em"
|
|
3843
|
+
| "embed"
|
|
3844
|
+
| "fieldset"
|
|
3845
|
+
| "figcaption"
|
|
3846
|
+
| "figure"
|
|
3847
|
+
| "footer"
|
|
3848
|
+
| "form"
|
|
3849
|
+
| "h1"
|
|
3850
|
+
| "h2"
|
|
3851
|
+
| "h3"
|
|
3852
|
+
| "h4"
|
|
3853
|
+
| "h5"
|
|
3854
|
+
| "h6"
|
|
3855
|
+
| "head"
|
|
3856
|
+
| "header"
|
|
3857
|
+
| "hgroup"
|
|
3858
|
+
| "hr"
|
|
3859
|
+
| "html"
|
|
3860
|
+
| "i"
|
|
3861
|
+
| "iframe"
|
|
3862
|
+
| "img"
|
|
3863
|
+
| "input"
|
|
3864
|
+
| "ins"
|
|
3865
|
+
| "kbd"
|
|
3866
|
+
| "keygen"
|
|
3867
|
+
| "label"
|
|
3868
|
+
| "legend"
|
|
3869
|
+
| "li"
|
|
3870
|
+
| "link"
|
|
3871
|
+
| "main"
|
|
3872
|
+
| "map"
|
|
3873
|
+
| "mark"
|
|
3874
|
+
| "menu"
|
|
3875
|
+
| "menuitem"
|
|
3876
|
+
| "meta"
|
|
3877
|
+
| "meter"
|
|
3878
|
+
| "nav"
|
|
3879
|
+
| "noscript"
|
|
3880
|
+
| "object"
|
|
3881
|
+
| "ol"
|
|
3882
|
+
| "optgroup"
|
|
3883
|
+
| "option"
|
|
3884
|
+
| "output"
|
|
3885
|
+
| "p"
|
|
3886
|
+
| "param"
|
|
3887
|
+
| "picture"
|
|
3888
|
+
| "pre"
|
|
3889
|
+
| "progress"
|
|
3890
|
+
| "q"
|
|
3891
|
+
| "rp"
|
|
3892
|
+
| "rt"
|
|
3893
|
+
| "ruby"
|
|
3894
|
+
| "s"
|
|
3895
|
+
| "samp"
|
|
3896
|
+
| "search"
|
|
3897
|
+
| "slot"
|
|
3898
|
+
| "script"
|
|
3899
|
+
| "section"
|
|
3900
|
+
| "select"
|
|
3901
|
+
| "small"
|
|
3902
|
+
| "source"
|
|
3903
|
+
| "span"
|
|
3904
|
+
| "strong"
|
|
3905
|
+
| "style"
|
|
3906
|
+
| "sub"
|
|
3907
|
+
| "summary"
|
|
3908
|
+
| "sup"
|
|
3909
|
+
| "table"
|
|
3910
|
+
| "template"
|
|
3911
|
+
| "tbody"
|
|
3912
|
+
| "td"
|
|
3913
|
+
| "textarea"
|
|
3914
|
+
| "tfoot"
|
|
3915
|
+
| "th"
|
|
3916
|
+
| "thead"
|
|
3917
|
+
| "time"
|
|
3918
|
+
| "title"
|
|
3919
|
+
| "tr"
|
|
3920
|
+
| "track"
|
|
3921
|
+
| "u"
|
|
3922
|
+
| "ul"
|
|
3923
|
+
| "var"
|
|
3924
|
+
| "video"
|
|
3925
|
+
| "wbr"
|
|
3926
|
+
| "webview";
|
|
3927
|
+
|
|
3928
|
+
// TODO: Move to react-dom
|
|
3929
|
+
type SVGElementType =
|
|
3930
|
+
| "animate"
|
|
3931
|
+
| "circle"
|
|
3932
|
+
| "clipPath"
|
|
3933
|
+
| "defs"
|
|
3934
|
+
| "desc"
|
|
3935
|
+
| "ellipse"
|
|
3936
|
+
| "feBlend"
|
|
3937
|
+
| "feColorMatrix"
|
|
3938
|
+
| "feComponentTransfer"
|
|
3939
|
+
| "feComposite"
|
|
3940
|
+
| "feConvolveMatrix"
|
|
3941
|
+
| "feDiffuseLighting"
|
|
3942
|
+
| "feDisplacementMap"
|
|
3943
|
+
| "feDistantLight"
|
|
3944
|
+
| "feDropShadow"
|
|
3945
|
+
| "feFlood"
|
|
3946
|
+
| "feFuncA"
|
|
3947
|
+
| "feFuncB"
|
|
3948
|
+
| "feFuncG"
|
|
3949
|
+
| "feFuncR"
|
|
3950
|
+
| "feGaussianBlur"
|
|
3951
|
+
| "feImage"
|
|
3952
|
+
| "feMerge"
|
|
3953
|
+
| "feMergeNode"
|
|
3954
|
+
| "feMorphology"
|
|
3955
|
+
| "feOffset"
|
|
3956
|
+
| "fePointLight"
|
|
3957
|
+
| "feSpecularLighting"
|
|
3958
|
+
| "feSpotLight"
|
|
3959
|
+
| "feTile"
|
|
3960
|
+
| "feTurbulence"
|
|
3961
|
+
| "filter"
|
|
3962
|
+
| "foreignObject"
|
|
3963
|
+
| "g"
|
|
3964
|
+
| "image"
|
|
3965
|
+
| "line"
|
|
3966
|
+
| "linearGradient"
|
|
3967
|
+
| "marker"
|
|
3968
|
+
| "mask"
|
|
3969
|
+
| "metadata"
|
|
3970
|
+
| "path"
|
|
3971
|
+
| "pattern"
|
|
3972
|
+
| "polygon"
|
|
3973
|
+
| "polyline"
|
|
3974
|
+
| "radialGradient"
|
|
3975
|
+
| "rect"
|
|
3976
|
+
| "stop"
|
|
3977
|
+
| "svg"
|
|
3978
|
+
| "switch"
|
|
3979
|
+
| "symbol"
|
|
3980
|
+
| "text"
|
|
3981
|
+
| "textPath"
|
|
3982
|
+
| "tspan"
|
|
3983
|
+
| "use"
|
|
3984
|
+
| "view";
|
|
4198
3985
|
|
|
4199
3986
|
//
|
|
4200
3987
|
// Browser Interfaces
|
|
@@ -4236,67 +4023,6 @@ declare namespace React {
|
|
|
4236
4023
|
}
|
|
4237
4024
|
|
|
4238
4025
|
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
|
4239
|
-
namespace JSX {
|
|
4240
|
-
interface Element extends GlobalJSXElement {}
|
|
4241
|
-
interface ElementClass extends GlobalJSXElementClass {}
|
|
4242
|
-
interface ElementAttributesProperty extends GlobalJSXElementAttributesProperty {}
|
|
4243
|
-
interface ElementChildrenAttribute extends GlobalJSXElementChildrenAttribute {}
|
|
4244
|
-
|
|
4245
|
-
type LibraryManagedAttributes<C, P> = GlobalJSXLibraryManagedAttributes<C, P>;
|
|
4246
|
-
|
|
4247
|
-
interface IntrinsicAttributes extends GlobalJSXIntrinsicAttributes {}
|
|
4248
|
-
interface IntrinsicClassAttributes<T> extends GlobalJSXIntrinsicClassAttributes<T> {}
|
|
4249
|
-
interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
|
|
4250
|
-
}
|
|
4251
|
-
}
|
|
4252
|
-
|
|
4253
|
-
// naked 'any' type in a conditional type will short circuit and union both the then/else branches
|
|
4254
|
-
// so boolean is only resolved for T = any
|
|
4255
|
-
type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
4256
|
-
|
|
4257
|
-
type ExactlyAnyPropertyKeys<T> = { [K in keyof T]: IsExactlyAny<T[K]> extends true ? K : never }[keyof T];
|
|
4258
|
-
type NotExactlyAnyPropertyKeys<T> = Exclude<keyof T, ExactlyAnyPropertyKeys<T>>;
|
|
4259
|
-
|
|
4260
|
-
// Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any
|
|
4261
|
-
type MergePropTypes<P, T> =
|
|
4262
|
-
// Distribute over P in case it is a union type
|
|
4263
|
-
P extends any
|
|
4264
|
-
// If props is type any, use propTypes definitions
|
|
4265
|
-
? IsExactlyAny<P> extends true ? T
|
|
4266
|
-
// If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
|
|
4267
|
-
: string extends keyof P ? P
|
|
4268
|
-
// Prefer declared types which are not exactly any
|
|
4269
|
-
:
|
|
4270
|
-
& Pick<P, NotExactlyAnyPropertyKeys<P>>
|
|
4271
|
-
// For props which are exactly any, use the type inferred from propTypes if present
|
|
4272
|
-
& Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
|
|
4273
|
-
// Keep leftover props not specified in propTypes
|
|
4274
|
-
& Pick<P, Exclude<keyof P, keyof T>>
|
|
4275
|
-
: never;
|
|
4276
|
-
|
|
4277
|
-
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
|
4278
|
-
|
|
4279
|
-
// Any prop that has a default prop becomes optional, but its type is unchanged
|
|
4280
|
-
// Undeclared default props are augmented into the resulting allowable attributes
|
|
4281
|
-
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
|
4282
|
-
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
|
4283
|
-
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
|
4284
|
-
:
|
|
4285
|
-
& Pick<P, Exclude<keyof P, keyof D>>
|
|
4286
|
-
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
|
4287
|
-
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
|
4288
|
-
: never;
|
|
4289
|
-
|
|
4290
|
-
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D }
|
|
4291
|
-
? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
|
|
4292
|
-
: C extends { propTypes: infer T } ? MergePropTypes<P, PropTypes.InferProps<T>>
|
|
4293
|
-
: C extends { defaultProps: infer D } ? Defaultize<P, D>
|
|
4294
|
-
: P;
|
|
4295
|
-
|
|
4296
|
-
declare global {
|
|
4297
|
-
/**
|
|
4298
|
-
* @deprecated Use `React.JSX` instead of the global `JSX` namespace.
|
|
4299
|
-
*/
|
|
4300
4026
|
namespace JSX {
|
|
4301
4027
|
interface Element extends React.ReactElement<any, any> {}
|
|
4302
4028
|
interface ElementClass extends React.Component<any> {
|
|
@@ -4508,17 +4234,18 @@ declare global {
|
|
|
4508
4234
|
}
|
|
4509
4235
|
}
|
|
4510
4236
|
|
|
4511
|
-
|
|
4512
|
-
// But we can't access global.JSX so we need to create these aliases instead.
|
|
4513
|
-
// Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
|
|
4514
|
-
interface GlobalJSXElement extends JSX.Element {}
|
|
4515
|
-
interface GlobalJSXElementClass extends JSX.ElementClass {}
|
|
4516
|
-
interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
|
|
4517
|
-
interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
|
|
4518
|
-
|
|
4519
|
-
type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
|
|
4237
|
+
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
|
4520
4238
|
|
|
4521
|
-
|
|
4522
|
-
|
|
4239
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
|
4240
|
+
// Undeclared default props are augmented into the resulting allowable attributes
|
|
4241
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
|
4242
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
|
4243
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
|
4244
|
+
:
|
|
4245
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
|
4246
|
+
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
|
4247
|
+
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
|
4248
|
+
: never;
|
|
4523
4249
|
|
|
4524
|
-
|
|
4250
|
+
type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
|
|
4251
|
+
: P;
|