@types/react 18.3.1 → 19.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- react/README.md +3 -3
- react/canary.d.ts +0 -128
- react/compiler-runtime.d.ts +4 -0
- react/experimental.d.ts +115 -17
- react/global.d.ts +6 -0
- react/index.d.ts +548 -785
- react/package.json +9 -9
- react/ts5.0/canary.d.ts +0 -128
- react/ts5.0/experimental.d.ts +115 -17
- react/ts5.0/global.d.ts +6 -0
- react/ts5.0/index.d.ts +544 -781
react/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
|
-
|
|
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
|
-
) => ReactNode)
|
|
125
|
-
| (new(
|
|
126
|
-
props: P,
|
|
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
|
+
) => ReactNode | Promise<ReactNode>)
|
|
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) => ReactNode)
|
|
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
|
* Different release channels declare additional types of ReactNode this particular release channel accepts.
|
|
444
393
|
* App or library types should never augment this interface.
|
|
@@ -479,6 +428,7 @@ declare namespace React {
|
|
|
479
428
|
| ReactElement
|
|
480
429
|
| string
|
|
481
430
|
| number
|
|
431
|
+
| bigint
|
|
482
432
|
| Iterable<ReactNode>
|
|
483
433
|
| ReactPortal
|
|
484
434
|
| boolean
|
|
@@ -486,36 +436,13 @@ declare namespace React {
|
|
|
486
436
|
| undefined
|
|
487
437
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
|
488
438
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
|
489
|
-
]
|
|
439
|
+
]
|
|
440
|
+
| Promise<AwaitedReactNode>;
|
|
490
441
|
|
|
491
442
|
//
|
|
492
443
|
// Top Level API
|
|
493
444
|
// ----------------------------------------------------------------------
|
|
494
445
|
|
|
495
|
-
// DOM Elements
|
|
496
|
-
/** @deprecated */
|
|
497
|
-
function createFactory<T extends HTMLElement>(
|
|
498
|
-
type: keyof ReactHTML,
|
|
499
|
-
): HTMLFactory<T>;
|
|
500
|
-
/** @deprecated */
|
|
501
|
-
function createFactory(
|
|
502
|
-
type: keyof ReactSVG,
|
|
503
|
-
): SVGFactory;
|
|
504
|
-
/** @deprecated */
|
|
505
|
-
function createFactory<P extends DOMAttributes<T>, T extends Element>(
|
|
506
|
-
type: string,
|
|
507
|
-
): DOMFactory<P, T>;
|
|
508
|
-
|
|
509
|
-
// Custom components
|
|
510
|
-
/** @deprecated */
|
|
511
|
-
function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
|
|
512
|
-
/** @deprecated */
|
|
513
|
-
function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
|
514
|
-
type: ClassType<P, T, C>,
|
|
515
|
-
): CFactory<P, T>;
|
|
516
|
-
/** @deprecated */
|
|
517
|
-
function createFactory<P>(type: ComponentClass<P>): Factory<P>;
|
|
518
|
-
|
|
519
446
|
// DOM Elements
|
|
520
447
|
// TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
|
|
521
448
|
function createElement(
|
|
@@ -524,12 +451,12 @@ declare namespace React {
|
|
|
524
451
|
...children: ReactNode[]
|
|
525
452
|
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
526
453
|
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
|
527
|
-
type:
|
|
454
|
+
type: HTMLElementType,
|
|
528
455
|
props?: ClassAttributes<T> & P | null,
|
|
529
456
|
...children: ReactNode[]
|
|
530
457
|
): DetailedReactHTMLElement<P, T>;
|
|
531
458
|
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
|
532
|
-
type:
|
|
459
|
+
type: SVGElementType,
|
|
533
460
|
props?: ClassAttributes<T> & P | null,
|
|
534
461
|
...children: ReactNode[]
|
|
535
462
|
): ReactSVGElement;
|
|
@@ -658,7 +585,6 @@ declare namespace React {
|
|
|
658
585
|
* @template P The props the component accepts.
|
|
659
586
|
*/
|
|
660
587
|
interface ProviderExoticComponent<P> extends ExoticComponent<P> {
|
|
661
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
662
588
|
}
|
|
663
589
|
|
|
664
590
|
/**
|
|
@@ -740,7 +666,7 @@ declare namespace React {
|
|
|
740
666
|
* const ThemeContext = createContext('light');
|
|
741
667
|
* ```
|
|
742
668
|
*/
|
|
743
|
-
interface Context<T> {
|
|
669
|
+
interface Context<T> extends Provider<T> {
|
|
744
670
|
Provider: Provider<T>;
|
|
745
671
|
Consumer: Consumer<T>;
|
|
746
672
|
/**
|
|
@@ -769,6 +695,13 @@ declare namespace React {
|
|
|
769
695
|
* import { createContext } from 'react';
|
|
770
696
|
*
|
|
771
697
|
* const ThemeContext = createContext('light');
|
|
698
|
+
* function App() {
|
|
699
|
+
* return (
|
|
700
|
+
* <ThemeContext value="dark">
|
|
701
|
+
* <Toolbar />
|
|
702
|
+
* </ThemeContext>
|
|
703
|
+
* );
|
|
704
|
+
* }
|
|
772
705
|
* ```
|
|
773
706
|
*/
|
|
774
707
|
function createContext<T>(
|
|
@@ -779,9 +712,6 @@ declare namespace React {
|
|
|
779
712
|
|
|
780
713
|
function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
|
|
781
714
|
|
|
782
|
-
/**
|
|
783
|
-
* Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
|
|
784
|
-
*/
|
|
785
715
|
const Children: {
|
|
786
716
|
map<T, C>(
|
|
787
717
|
children: C | readonly C[],
|
|
@@ -792,6 +722,10 @@ declare namespace React {
|
|
|
792
722
|
only<C>(children: C): C extends any[] ? never : C;
|
|
793
723
|
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
|
794
724
|
};
|
|
725
|
+
|
|
726
|
+
export interface FragmentProps {
|
|
727
|
+
children?: React.ReactNode;
|
|
728
|
+
}
|
|
795
729
|
/**
|
|
796
730
|
* Lets you group elements without a wrapper node.
|
|
797
731
|
*
|
|
@@ -819,7 +753,7 @@ declare namespace React {
|
|
|
819
753
|
* </>
|
|
820
754
|
* ```
|
|
821
755
|
*/
|
|
822
|
-
const Fragment: ExoticComponent<
|
|
756
|
+
const Fragment: ExoticComponent<FragmentProps>;
|
|
823
757
|
|
|
824
758
|
/**
|
|
825
759
|
* Lets you find common bugs in your components early during development.
|
|
@@ -848,6 +782,12 @@ declare namespace React {
|
|
|
848
782
|
|
|
849
783
|
/** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
|
|
850
784
|
fallback?: ReactNode;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* A name for this Suspense boundary for instrumentation purposes.
|
|
788
|
+
* The name will help identify this boundary in React DevTools.
|
|
789
|
+
*/
|
|
790
|
+
name?: string | undefined;
|
|
851
791
|
}
|
|
852
792
|
|
|
853
793
|
/**
|
|
@@ -982,7 +922,13 @@ declare namespace React {
|
|
|
982
922
|
static contextType?: Context<any> | undefined;
|
|
983
923
|
|
|
984
924
|
/**
|
|
985
|
-
*
|
|
925
|
+
* Ignored by React.
|
|
926
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
927
|
+
*/
|
|
928
|
+
static propTypes?: any;
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* If using React Context, re-declare this in your class to be the
|
|
986
932
|
* `React.ContextType` of your `static contextType`.
|
|
987
933
|
* Should be used with type annotation or static contextType.
|
|
988
934
|
*
|
|
@@ -999,11 +945,15 @@ declare namespace React {
|
|
|
999
945
|
*/
|
|
1000
946
|
context: unknown;
|
|
1001
947
|
|
|
948
|
+
// Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
|
|
1002
949
|
constructor(props: P);
|
|
1003
950
|
/**
|
|
1004
|
-
* @
|
|
1005
|
-
* @
|
|
951
|
+
* @param props
|
|
952
|
+
* @param context value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
|
|
953
|
+
* in `contextType`.
|
|
1006
954
|
*/
|
|
955
|
+
// TODO: Ideally we'd infer the constructor signatur from `contextType`.
|
|
956
|
+
// Might be hard to ship without breaking existing code.
|
|
1007
957
|
constructor(props: P, context: any);
|
|
1008
958
|
|
|
1009
959
|
// We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
|
|
@@ -1019,14 +969,6 @@ declare namespace React {
|
|
|
1019
969
|
|
|
1020
970
|
readonly props: Readonly<P>;
|
|
1021
971
|
state: Readonly<S>;
|
|
1022
|
-
/**
|
|
1023
|
-
* @deprecated
|
|
1024
|
-
*
|
|
1025
|
-
* @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
|
|
1026
|
-
*/
|
|
1027
|
-
refs: {
|
|
1028
|
-
[key: string]: ReactInstance;
|
|
1029
|
-
};
|
|
1030
972
|
}
|
|
1031
973
|
|
|
1032
974
|
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
|
|
@@ -1043,10 +985,6 @@ declare namespace React {
|
|
|
1043
985
|
getInitialState?(): S;
|
|
1044
986
|
}
|
|
1045
987
|
|
|
1046
|
-
interface ChildContextProvider<CC> {
|
|
1047
|
-
getChildContext(): CC;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
988
|
//
|
|
1051
989
|
// Class Interfaces
|
|
1052
990
|
// ----------------------------------------------------------------------
|
|
@@ -1111,58 +1049,12 @@ declare namespace React {
|
|
|
1111
1049
|
* ```
|
|
1112
1050
|
*/
|
|
1113
1051
|
interface FunctionComponent<P = {}> {
|
|
1114
|
-
(
|
|
1115
|
-
props: P,
|
|
1116
|
-
/**
|
|
1117
|
-
* @deprecated
|
|
1118
|
-
*
|
|
1119
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
|
1120
|
-
*/
|
|
1121
|
-
deprecatedLegacyContext?: any,
|
|
1122
|
-
): ReactNode;
|
|
1123
|
-
/**
|
|
1124
|
-
* Used to declare the types of the props accepted by the
|
|
1125
|
-
* component. These types will be checked during rendering
|
|
1126
|
-
* and in development only.
|
|
1127
|
-
*
|
|
1128
|
-
* We recommend using TypeScript instead of checking prop
|
|
1129
|
-
* types at runtime.
|
|
1130
|
-
*
|
|
1131
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
|
1132
|
-
*/
|
|
1133
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
1052
|
+
(props: P): ReactNode | Promise<ReactNode>;
|
|
1134
1053
|
/**
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
* Lets you specify which legacy context is consumed by
|
|
1138
|
-
* this component.
|
|
1139
|
-
*
|
|
1140
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
|
1141
|
-
*/
|
|
1142
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1143
|
-
/**
|
|
1144
|
-
* Used to define default values for the props accepted by
|
|
1145
|
-
* the component.
|
|
1146
|
-
*
|
|
1147
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
|
1148
|
-
*
|
|
1149
|
-
* @example
|
|
1150
|
-
*
|
|
1151
|
-
* ```tsx
|
|
1152
|
-
* type Props = { name?: string }
|
|
1153
|
-
*
|
|
1154
|
-
* const MyComponent: FC<Props> = (props) => {
|
|
1155
|
-
* return <div>{props.name}</div>
|
|
1156
|
-
* }
|
|
1157
|
-
*
|
|
1158
|
-
* MyComponent.defaultProps = {
|
|
1159
|
-
* name: 'John Doe'
|
|
1160
|
-
* }
|
|
1161
|
-
* ```
|
|
1162
|
-
*
|
|
1163
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
|
1054
|
+
* Ignored by React.
|
|
1055
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1164
1056
|
*/
|
|
1165
|
-
|
|
1057
|
+
propTypes?: any;
|
|
1166
1058
|
/**
|
|
1167
1059
|
* Used in debugging messages. You might want to set it
|
|
1168
1060
|
* explicitly if you want to display a different name for
|
|
@@ -1184,44 +1076,14 @@ declare namespace React {
|
|
|
1184
1076
|
displayName?: string | undefined;
|
|
1185
1077
|
}
|
|
1186
1078
|
|
|
1187
|
-
/**
|
|
1188
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
|
1189
|
-
*
|
|
1190
|
-
* @see {@link React.FunctionComponent}
|
|
1191
|
-
* @alias {@link VoidFunctionComponent}
|
|
1192
|
-
*/
|
|
1193
|
-
type VFC<P = {}> = VoidFunctionComponent<P>;
|
|
1194
|
-
|
|
1195
|
-
/**
|
|
1196
|
-
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
|
1197
|
-
*
|
|
1198
|
-
* @see {@link React.FunctionComponent}
|
|
1199
|
-
*/
|
|
1200
|
-
interface VoidFunctionComponent<P = {}> {
|
|
1201
|
-
(
|
|
1202
|
-
props: P,
|
|
1203
|
-
/**
|
|
1204
|
-
* @deprecated
|
|
1205
|
-
*
|
|
1206
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
|
1207
|
-
*/
|
|
1208
|
-
deprecatedLegacyContext?: any,
|
|
1209
|
-
): ReactNode;
|
|
1210
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
1211
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1212
|
-
/**
|
|
1213
|
-
* @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
|
|
1214
|
-
*/
|
|
1215
|
-
defaultProps?: Partial<P> | undefined;
|
|
1216
|
-
displayName?: string | undefined;
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
1079
|
/**
|
|
1220
1080
|
* The type of the ref received by a {@link ForwardRefRenderFunction}.
|
|
1221
1081
|
*
|
|
1222
1082
|
* @see {@link ForwardRefRenderFunction}
|
|
1223
1083
|
*/
|
|
1224
|
-
|
|
1084
|
+
// Making T nullable is assuming the refs will be managed by React or the component impl will write it somewhere else.
|
|
1085
|
+
// But this isn't necessarily true. We haven't heard complains about it yet and hopefully `forwardRef` is removed from React before we do.
|
|
1086
|
+
type ForwardedRef<T> = ((instance: T | null) => void) | RefObject<T | null> | null;
|
|
1225
1087
|
|
|
1226
1088
|
/**
|
|
1227
1089
|
* The type of the function passed to {@link forwardRef}. This is considered different
|
|
@@ -1250,19 +1112,10 @@ declare namespace React {
|
|
|
1250
1112
|
*/
|
|
1251
1113
|
displayName?: string | undefined;
|
|
1252
1114
|
/**
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
|
1256
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
|
1257
|
-
*/
|
|
1258
|
-
defaultProps?: never | undefined;
|
|
1259
|
-
/**
|
|
1260
|
-
* propTypes are not supported on render functions passed to forwardRef.
|
|
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-proptypes React Docs}
|
|
1115
|
+
* Ignored by React.
|
|
1116
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1264
1117
|
*/
|
|
1265
|
-
propTypes?:
|
|
1118
|
+
propTypes?: any;
|
|
1266
1119
|
}
|
|
1267
1120
|
|
|
1268
1121
|
/**
|
|
@@ -1272,48 +1125,21 @@ declare namespace React {
|
|
|
1272
1125
|
* @template S The internal state of the component.
|
|
1273
1126
|
*/
|
|
1274
1127
|
interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
|
|
1128
|
+
// constructor signature must match React.Component
|
|
1275
1129
|
new(
|
|
1276
1130
|
props: P,
|
|
1277
1131
|
/**
|
|
1278
|
-
* @
|
|
1279
|
-
*
|
|
1280
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
|
|
1132
|
+
* Value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
|
|
1133
|
+
* in `contextType`.
|
|
1281
1134
|
*/
|
|
1282
|
-
|
|
1135
|
+
context?: any,
|
|
1283
1136
|
): Component<P, S>;
|
|
1284
1137
|
/**
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1287
|
-
* and in development only.
|
|
1288
|
-
*
|
|
1289
|
-
* We recommend using TypeScript instead of checking prop
|
|
1290
|
-
* types at runtime.
|
|
1291
|
-
*
|
|
1292
|
-
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
|
1138
|
+
* Ignored by React.
|
|
1139
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1293
1140
|
*/
|
|
1294
|
-
propTypes?:
|
|
1141
|
+
propTypes?: any;
|
|
1295
1142
|
contextType?: Context<any> | undefined;
|
|
1296
|
-
/**
|
|
1297
|
-
* @deprecated use {@link ComponentClass.contextType} instead
|
|
1298
|
-
*
|
|
1299
|
-
* Lets you specify which legacy context is consumed by
|
|
1300
|
-
* this component.
|
|
1301
|
-
*
|
|
1302
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
|
|
1303
|
-
*/
|
|
1304
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1305
|
-
/**
|
|
1306
|
-
* @deprecated
|
|
1307
|
-
*
|
|
1308
|
-
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
|
|
1309
|
-
*/
|
|
1310
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
|
1311
|
-
/**
|
|
1312
|
-
* Used to define default values for the props accepted by
|
|
1313
|
-
* the component.
|
|
1314
|
-
*
|
|
1315
|
-
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
|
1316
|
-
*/
|
|
1317
1143
|
defaultProps?: Partial<P> | undefined;
|
|
1318
1144
|
/**
|
|
1319
1145
|
* Used in debugging messages. You might want to set it
|
|
@@ -1332,7 +1158,7 @@ declare namespace React {
|
|
|
1332
1158
|
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
|
1333
1159
|
*/
|
|
1334
1160
|
interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
|
|
1335
|
-
new(props: P
|
|
1161
|
+
new(props: P): ClassicComponent<P, ComponentState>;
|
|
1336
1162
|
getDefaultProps?(): P;
|
|
1337
1163
|
}
|
|
1338
1164
|
|
|
@@ -1347,7 +1173,7 @@ declare namespace React {
|
|
|
1347
1173
|
*/
|
|
1348
1174
|
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
|
1349
1175
|
& C
|
|
1350
|
-
& (new(props: P,
|
|
1176
|
+
& (new(props: P, context: any) => T);
|
|
1351
1177
|
|
|
1352
1178
|
//
|
|
1353
1179
|
// Component Specs and Lifecycle
|
|
@@ -1521,38 +1347,7 @@ declare namespace React {
|
|
|
1521
1347
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
|
|
1522
1348
|
}
|
|
1523
1349
|
|
|
1524
|
-
|
|
1525
|
-
* @deprecated
|
|
1526
|
-
*
|
|
1527
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
|
1528
|
-
*/
|
|
1529
|
-
interface Mixin<P, S> extends ComponentLifecycle<P, S> {
|
|
1530
|
-
mixins?: Array<Mixin<P, S>> | undefined;
|
|
1531
|
-
statics?: {
|
|
1532
|
-
[key: string]: any;
|
|
1533
|
-
} | undefined;
|
|
1534
|
-
|
|
1535
|
-
displayName?: string | undefined;
|
|
1536
|
-
propTypes?: ValidationMap<any> | undefined;
|
|
1537
|
-
contextTypes?: ValidationMap<any> | undefined;
|
|
1538
|
-
childContextTypes?: ValidationMap<any> | undefined;
|
|
1539
|
-
|
|
1540
|
-
getDefaultProps?(): P;
|
|
1541
|
-
getInitialState?(): S;
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
/**
|
|
1545
|
-
* @deprecated
|
|
1546
|
-
*
|
|
1547
|
-
* @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
|
|
1548
|
-
*/
|
|
1549
|
-
interface ComponentSpec<P, S> extends Mixin<P, S> {
|
|
1550
|
-
render(): ReactNode;
|
|
1551
|
-
|
|
1552
|
-
[propertyName: string]: any;
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
function createRef<T>(): RefObject<T>;
|
|
1350
|
+
function createRef<T>(): RefObject<T | null>;
|
|
1556
1351
|
|
|
1557
1352
|
/**
|
|
1558
1353
|
* The type of the component returned from {@link forwardRef}.
|
|
@@ -1563,10 +1358,10 @@ declare namespace React {
|
|
|
1563
1358
|
*/
|
|
1564
1359
|
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
|
1565
1360
|
/**
|
|
1566
|
-
*
|
|
1361
|
+
* Ignored by React.
|
|
1362
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1567
1363
|
*/
|
|
1568
|
-
|
|
1569
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
1364
|
+
propTypes?: any;
|
|
1570
1365
|
}
|
|
1571
1366
|
|
|
1572
1367
|
/**
|
|
@@ -1597,29 +1392,24 @@ declare namespace React {
|
|
|
1597
1392
|
* ```
|
|
1598
1393
|
*/
|
|
1599
1394
|
function forwardRef<T, P = {}>(
|
|
1600
|
-
render: ForwardRefRenderFunction<T, P
|
|
1395
|
+
render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
|
|
1601
1396
|
): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
1602
1397
|
|
|
1603
1398
|
/**
|
|
1604
1399
|
* Omits the 'ref' attribute from the given props object.
|
|
1605
1400
|
*
|
|
1606
|
-
* @template
|
|
1401
|
+
* @template Props The props object type.
|
|
1607
1402
|
*/
|
|
1608
|
-
type PropsWithoutRef<
|
|
1403
|
+
type PropsWithoutRef<Props> =
|
|
1609
1404
|
// Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
|
|
1610
1405
|
// see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
|
1611
1406
|
// https://github.com/Microsoft/TypeScript/issues/28339
|
|
1612
|
-
|
|
1613
|
-
/**
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
? P extends { ref?: infer R | undefined }
|
|
1619
|
-
? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
|
1620
|
-
: P
|
|
1621
|
-
: P
|
|
1622
|
-
: P;
|
|
1407
|
+
Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
|
|
1408
|
+
/**
|
|
1409
|
+
* Ensures that the props do not include string ref, which cannot be forwarded
|
|
1410
|
+
* @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
|
|
1411
|
+
*/
|
|
1412
|
+
type PropsWithRef<Props> = Props;
|
|
1623
1413
|
|
|
1624
1414
|
type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
|
|
1625
1415
|
|
|
@@ -1651,7 +1441,7 @@ declare namespace React {
|
|
|
1651
1441
|
* ```
|
|
1652
1442
|
*/
|
|
1653
1443
|
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
|
1654
|
-
JSXElementConstructor<infer
|
|
1444
|
+
JSXElementConstructor<infer Props> ? Props
|
|
1655
1445
|
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
|
1656
1446
|
: {};
|
|
1657
1447
|
|
|
@@ -1678,9 +1468,11 @@ declare namespace React {
|
|
|
1678
1468
|
* type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
|
|
1679
1469
|
* ```
|
|
1680
1470
|
*/
|
|
1681
|
-
type ComponentPropsWithRef<T extends ElementType> = T extends
|
|
1682
|
-
|
|
1683
|
-
:
|
|
1471
|
+
type ComponentPropsWithRef<T extends ElementType> = 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
|
|
1475
|
+
: ComponentProps<T>;
|
|
1684
1476
|
/**
|
|
1685
1477
|
* Used to retrieve the props a custom component accepts with its ref.
|
|
1686
1478
|
*
|
|
@@ -1697,9 +1489,10 @@ declare namespace React {
|
|
|
1697
1489
|
* type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
|
|
1698
1490
|
* ```
|
|
1699
1491
|
*/
|
|
1700
|
-
type CustomComponentPropsWithRef<T extends ComponentType> = T extends
|
|
1701
|
-
|
|
1702
|
-
|
|
1492
|
+
type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
|
|
1493
|
+
// If it's a class i.e. newable we're dealing with a class component
|
|
1494
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
|
1495
|
+
: Props
|
|
1703
1496
|
: never;
|
|
1704
1497
|
|
|
1705
1498
|
/**
|
|
@@ -1727,10 +1520,24 @@ declare namespace React {
|
|
|
1727
1520
|
*/
|
|
1728
1521
|
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
|
1729
1522
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1523
|
+
/**
|
|
1524
|
+
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
|
1525
|
+
*
|
|
1526
|
+
* @template C The component type.
|
|
1527
|
+
*
|
|
1528
|
+
* @example
|
|
1529
|
+
*
|
|
1530
|
+
* ```tsx
|
|
1531
|
+
* type MyComponentRef = React.ComponentRef<typeof MyComponent>;
|
|
1532
|
+
* ```
|
|
1533
|
+
*
|
|
1534
|
+
* @example
|
|
1535
|
+
*
|
|
1536
|
+
* ```tsx
|
|
1537
|
+
* type DivRef = React.ComponentRef<'div'>;
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
|
1734
1541
|
: never;
|
|
1735
1542
|
|
|
1736
1543
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
|
@@ -1831,6 +1638,11 @@ declare namespace React {
|
|
|
1831
1638
|
* A {@link Dispatch} function can sometimes be called without any arguments.
|
|
1832
1639
|
*/
|
|
1833
1640
|
type DispatchWithoutAction = () => void;
|
|
1641
|
+
// Limit the reducer to accept only 0 or 1 action arguments
|
|
1642
|
+
// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
|
|
1643
|
+
type AnyActionArg = [] | [any];
|
|
1644
|
+
// Get the dispatch type from the reducer arguments (captures optional action argument correctly)
|
|
1645
|
+
type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
|
|
1834
1646
|
// Unlike redux, the actions _can_ be anything
|
|
1835
1647
|
type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
1836
1648
|
// If useReducer accepts a reducer without action, dispatch may be called without any parameters.
|
|
@@ -1838,15 +1650,14 @@ declare namespace React {
|
|
|
1838
1650
|
// types used to try and prevent the compiler from reducing S
|
|
1839
1651
|
// to a supertype common with the second argument to useReducer()
|
|
1840
1652
|
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
|
1841
|
-
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
|
1842
|
-
// The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
|
|
1843
|
-
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
|
|
1844
|
-
: never;
|
|
1845
1653
|
type DependencyList = readonly unknown[];
|
|
1846
1654
|
|
|
1847
1655
|
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
|
1848
1656
|
type EffectCallback = () => void | Destructor;
|
|
1849
1657
|
|
|
1658
|
+
/**
|
|
1659
|
+
* @deprecated Use `RefObject` instead.
|
|
1660
|
+
*/
|
|
1850
1661
|
interface MutableRefObject<T> {
|
|
1851
1662
|
current: T;
|
|
1852
1663
|
}
|
|
@@ -1885,62 +1696,10 @@ declare namespace React {
|
|
|
1885
1696
|
* @version 16.8.0
|
|
1886
1697
|
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1887
1698
|
*/
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
initializer: (arg: I) => ReducerStateWithoutAction<R>,
|
|
1893
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
|
1894
|
-
/**
|
|
1895
|
-
* An alternative to `useState`.
|
|
1896
|
-
*
|
|
1897
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1898
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1899
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1900
|
-
*
|
|
1901
|
-
* @version 16.8.0
|
|
1902
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1903
|
-
*/
|
|
1904
|
-
// overload where dispatch could accept 0 arguments.
|
|
1905
|
-
function useReducer<R extends ReducerWithoutAction<any>>(
|
|
1906
|
-
reducer: R,
|
|
1907
|
-
initializerArg: ReducerStateWithoutAction<R>,
|
|
1908
|
-
initializer?: undefined,
|
|
1909
|
-
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
|
1910
|
-
/**
|
|
1911
|
-
* An alternative to `useState`.
|
|
1912
|
-
*
|
|
1913
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1914
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1915
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1916
|
-
*
|
|
1917
|
-
* @version 16.8.0
|
|
1918
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1919
|
-
*/
|
|
1920
|
-
// overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
|
|
1921
|
-
// If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
|
|
1922
|
-
// the last overload effectively behaves as if the identity function (x => x) is the initializer.
|
|
1923
|
-
function useReducer<R extends Reducer<any, any>, I>(
|
|
1924
|
-
reducer: R,
|
|
1925
|
-
initializerArg: I & ReducerState<R>,
|
|
1926
|
-
initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
|
|
1927
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
|
1928
|
-
/**
|
|
1929
|
-
* An alternative to `useState`.
|
|
1930
|
-
*
|
|
1931
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1932
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1933
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1934
|
-
*
|
|
1935
|
-
* @version 16.8.0
|
|
1936
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1937
|
-
*/
|
|
1938
|
-
// overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
|
|
1939
|
-
function useReducer<R extends Reducer<any, any>, I>(
|
|
1940
|
-
reducer: R,
|
|
1941
|
-
initializerArg: I,
|
|
1942
|
-
initializer: (arg: I) => ReducerState<R>,
|
|
1943
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
|
1699
|
+
function useReducer<S, A extends AnyActionArg>(
|
|
1700
|
+
reducer: (prevState: S, ...args: A) => S,
|
|
1701
|
+
initialState: S,
|
|
1702
|
+
): [S, ActionDispatch<A>];
|
|
1944
1703
|
/**
|
|
1945
1704
|
* An alternative to `useState`.
|
|
1946
1705
|
*
|
|
@@ -1951,21 +1710,11 @@ declare namespace React {
|
|
|
1951
1710
|
* @version 16.8.0
|
|
1952
1711
|
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1953
1712
|
*/
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
// supertype between the reducer's return type and the initialState (or the initializer's return type),
|
|
1960
|
-
// which would prevent autocompletion from ever working.
|
|
1961
|
-
|
|
1962
|
-
// TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
|
|
1963
|
-
// in older versions, or a regression in newer versions of the typescript completion service.
|
|
1964
|
-
function useReducer<R extends Reducer<any, any>>(
|
|
1965
|
-
reducer: R,
|
|
1966
|
-
initialState: ReducerState<R>,
|
|
1967
|
-
initializer?: undefined,
|
|
1968
|
-
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
|
1713
|
+
function useReducer<S, I, A extends AnyActionArg>(
|
|
1714
|
+
reducer: (prevState: S, ...args: A) => S,
|
|
1715
|
+
initialArg: I,
|
|
1716
|
+
init: (i: I) => S,
|
|
1717
|
+
): [S, ActionDispatch<A>];
|
|
1969
1718
|
/**
|
|
1970
1719
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
1971
1720
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
|
@@ -1976,7 +1725,7 @@ declare namespace React {
|
|
|
1976
1725
|
* @version 16.8.0
|
|
1977
1726
|
* @see {@link https://react.dev/reference/react/useRef}
|
|
1978
1727
|
*/
|
|
1979
|
-
function useRef<T>(initialValue: T):
|
|
1728
|
+
function useRef<T>(initialValue: T): RefObject<T>;
|
|
1980
1729
|
// convenience overload for refs given as a ref prop as they typically start with a null value
|
|
1981
1730
|
/**
|
|
1982
1731
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
@@ -1985,15 +1734,11 @@ declare namespace React {
|
|
|
1985
1734
|
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
|
1986
1735
|
* value around similar to how you’d use instance fields in classes.
|
|
1987
1736
|
*
|
|
1988
|
-
* Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
|
|
1989
|
-
* of the generic argument.
|
|
1990
|
-
*
|
|
1991
1737
|
* @version 16.8.0
|
|
1992
1738
|
* @see {@link https://react.dev/reference/react/useRef}
|
|
1993
1739
|
*/
|
|
1994
|
-
function useRef<T>(initialValue: T | null): RefObject<T>;
|
|
1995
|
-
// convenience overload for
|
|
1996
|
-
// has a default to stop it from defaulting to {} instead
|
|
1740
|
+
function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
1741
|
+
// convenience overload for undefined initialValue
|
|
1997
1742
|
/**
|
|
1998
1743
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
1999
1744
|
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
|
@@ -2004,7 +1749,7 @@ declare namespace React {
|
|
|
2004
1749
|
* @version 16.8.0
|
|
2005
1750
|
* @see {@link https://react.dev/reference/react/useRef}
|
|
2006
1751
|
*/
|
|
2007
|
-
function useRef<T
|
|
1752
|
+
function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
|
2008
1753
|
/**
|
|
2009
1754
|
* The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
|
|
2010
1755
|
* Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
|
|
@@ -2029,13 +1774,17 @@ declare namespace React {
|
|
|
2029
1774
|
* @see {@link https://react.dev/reference/react/useEffect}
|
|
2030
1775
|
*/
|
|
2031
1776
|
function useEffect(effect: EffectCallback, deps?: DependencyList): void;
|
|
1777
|
+
/**
|
|
1778
|
+
* @see {@link https://react.dev/reference/react/useEffectEvent `useEffectEvent()` documentation}
|
|
1779
|
+
* @version 19.2.0
|
|
1780
|
+
*/
|
|
1781
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
1782
|
+
export function useEffectEvent<T extends Function>(callback: T): T;
|
|
2032
1783
|
// NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref<T>
|
|
2033
1784
|
/**
|
|
2034
1785
|
* `useImperativeHandle` customizes the instance value that is exposed to parent components when using
|
|
2035
1786
|
* `ref`. As always, imperative code using refs should be avoided in most cases.
|
|
2036
1787
|
*
|
|
2037
|
-
* `useImperativeHandle` should be used with `React.forwardRef`.
|
|
2038
|
-
*
|
|
2039
1788
|
* @version 16.8.0
|
|
2040
1789
|
* @see {@link https://react.dev/reference/react/useImperativeHandle}
|
|
2041
1790
|
*/
|
|
@@ -2051,7 +1800,7 @@ declare namespace React {
|
|
|
2051
1800
|
*/
|
|
2052
1801
|
// A specific function type would not trigger implicit any.
|
|
2053
1802
|
// See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
|
|
2054
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
1803
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2055
1804
|
function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
|
|
2056
1805
|
/**
|
|
2057
1806
|
* `useMemo` will only recompute the memoized value when one of the `deps` has changed.
|
|
@@ -2074,8 +1823,7 @@ declare namespace React {
|
|
|
2074
1823
|
// it's just the function name without the "use" prefix.
|
|
2075
1824
|
function useDebugValue<T>(value: T, format?: (value: T) => any): void;
|
|
2076
1825
|
|
|
2077
|
-
|
|
2078
|
-
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
|
1826
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
|
|
2079
1827
|
// strange definition to allow vscode to show documentation on the invocation
|
|
2080
1828
|
export interface TransitionStartFunction {
|
|
2081
1829
|
/**
|
|
@@ -2083,7 +1831,7 @@ declare namespace React {
|
|
|
2083
1831
|
*
|
|
2084
1832
|
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
|
2085
1833
|
*
|
|
2086
|
-
* @param callback A
|
|
1834
|
+
* @param callback A function which causes state updates that can be deferred.
|
|
2087
1835
|
*/
|
|
2088
1836
|
(callback: TransitionFunction): void;
|
|
2089
1837
|
}
|
|
@@ -2097,10 +1845,11 @@ declare namespace React {
|
|
|
2097
1845
|
* A good example of this is a text input.
|
|
2098
1846
|
*
|
|
2099
1847
|
* @param value The value that is going to be deferred
|
|
1848
|
+
* @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.
|
|
2100
1849
|
*
|
|
2101
1850
|
* @see {@link https://react.dev/reference/react/useDeferredValue}
|
|
2102
1851
|
*/
|
|
2103
|
-
export function useDeferredValue<T>(value: T): T;
|
|
1852
|
+
export function useDeferredValue<T>(value: T, initialValue?: T): T;
|
|
2104
1853
|
|
|
2105
1854
|
/**
|
|
2106
1855
|
* Allows components to avoid undesirable loading states by waiting for content to load
|
|
@@ -2122,7 +1871,7 @@ declare namespace React {
|
|
|
2122
1871
|
/**
|
|
2123
1872
|
* Similar to `useTransition` but allows uses where hooks are not available.
|
|
2124
1873
|
*
|
|
2125
|
-
* @param callback A
|
|
1874
|
+
* @param callback A function which causes state updates that can be deferred.
|
|
2126
1875
|
*/
|
|
2127
1876
|
export function startTransition(scope: TransitionFunction): void;
|
|
2128
1877
|
|
|
@@ -2137,6 +1886,11 @@ declare namespace React {
|
|
|
2137
1886
|
*
|
|
2138
1887
|
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
|
2139
1888
|
*/
|
|
1889
|
+
// NOTES
|
|
1890
|
+
// - the order of these signatures matters - typescript will check the signatures in source order.
|
|
1891
|
+
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
|
|
1892
|
+
// `strictNullChecks: false`.
|
|
1893
|
+
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
|
|
2140
1894
|
// 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.
|
|
2141
1895
|
export function act(callback: () => VoidOrUndefinedOnly): void;
|
|
2142
1896
|
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
@@ -2164,6 +1918,68 @@ declare namespace React {
|
|
|
2164
1918
|
getServerSnapshot?: () => Snapshot,
|
|
2165
1919
|
): Snapshot;
|
|
2166
1920
|
|
|
1921
|
+
export function useOptimistic<State>(
|
|
1922
|
+
passthrough: State,
|
|
1923
|
+
): [State, (action: State | ((pendingState: State) => State)) => void];
|
|
1924
|
+
export function useOptimistic<State, Action>(
|
|
1925
|
+
passthrough: State,
|
|
1926
|
+
reducer: (state: State, action: Action) => State,
|
|
1927
|
+
): [State, (action: Action) => void];
|
|
1928
|
+
|
|
1929
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
|
1930
|
+
|
|
1931
|
+
export function use<T>(usable: Usable<T>): T;
|
|
1932
|
+
|
|
1933
|
+
export function useActionState<State>(
|
|
1934
|
+
action: (state: Awaited<State>) => State | Promise<State>,
|
|
1935
|
+
initialState: Awaited<State>,
|
|
1936
|
+
permalink?: string,
|
|
1937
|
+
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
|
1938
|
+
export function useActionState<State, Payload>(
|
|
1939
|
+
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
|
1940
|
+
initialState: Awaited<State>,
|
|
1941
|
+
permalink?: string,
|
|
1942
|
+
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
1943
|
+
|
|
1944
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
1945
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
|
1946
|
+
|
|
1947
|
+
export interface CacheSignal {}
|
|
1948
|
+
/**
|
|
1949
|
+
* @version 19.2.0
|
|
1950
|
+
*/
|
|
1951
|
+
export function cacheSignal(): null | CacheSignal;
|
|
1952
|
+
|
|
1953
|
+
export interface ActivityProps {
|
|
1954
|
+
/**
|
|
1955
|
+
* @default "visible"
|
|
1956
|
+
*/
|
|
1957
|
+
mode?:
|
|
1958
|
+
| "hidden"
|
|
1959
|
+
| "visible"
|
|
1960
|
+
| undefined;
|
|
1961
|
+
/**
|
|
1962
|
+
* A name for this Activity boundary for instrumentation purposes.
|
|
1963
|
+
* The name will help identify this boundary in React DevTools.
|
|
1964
|
+
*/
|
|
1965
|
+
name?: string | undefined;
|
|
1966
|
+
children: ReactNode;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation}
|
|
1971
|
+
* @version 19.2.0
|
|
1972
|
+
*/
|
|
1973
|
+
export const Activity: ExoticComponent<ActivityProps>;
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Warning: Only available in development builds.
|
|
1977
|
+
*
|
|
1978
|
+
* @see {@link https://react.dev/reference/react/captureOwnerStack Reference docs}
|
|
1979
|
+
* @version 19.1.0
|
|
1980
|
+
*/
|
|
1981
|
+
function captureOwnerStack(): string | null;
|
|
1982
|
+
|
|
2167
1983
|
//
|
|
2168
1984
|
// Event System
|
|
2169
1985
|
// ----------------------------------------------------------------------
|
|
@@ -2236,6 +2052,10 @@ declare namespace React {
|
|
|
2236
2052
|
target: EventTarget & T;
|
|
2237
2053
|
}
|
|
2238
2054
|
|
|
2055
|
+
interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
|
|
2056
|
+
data: string;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2239
2059
|
export type ModifierKey =
|
|
2240
2060
|
| "Alt"
|
|
2241
2061
|
| "AltGraph"
|
|
@@ -2331,6 +2151,11 @@ declare namespace React {
|
|
|
2331
2151
|
pseudoElement: string;
|
|
2332
2152
|
}
|
|
2333
2153
|
|
|
2154
|
+
interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
|
|
2155
|
+
oldState: "closed" | "open";
|
|
2156
|
+
newState: "closed" | "open";
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2334
2159
|
interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
|
|
2335
2160
|
elapsedTime: number;
|
|
2336
2161
|
propertyName: string;
|
|
@@ -2351,6 +2176,7 @@ declare namespace React {
|
|
|
2351
2176
|
type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
|
|
2352
2177
|
type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
|
|
2353
2178
|
type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
|
|
2179
|
+
type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
|
|
2354
2180
|
type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
|
|
2355
2181
|
type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
|
|
2356
2182
|
type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
|
|
@@ -2358,6 +2184,7 @@ declare namespace React {
|
|
|
2358
2184
|
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
|
2359
2185
|
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
|
|
2360
2186
|
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
|
|
2187
|
+
type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
|
|
2361
2188
|
type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
|
|
2362
2189
|
|
|
2363
2190
|
//
|
|
@@ -2408,7 +2235,7 @@ declare namespace React {
|
|
|
2408
2235
|
// Form Events
|
|
2409
2236
|
onChange?: FormEventHandler<T> | undefined;
|
|
2410
2237
|
onChangeCapture?: FormEventHandler<T> | undefined;
|
|
2411
|
-
onBeforeInput?:
|
|
2238
|
+
onBeforeInput?: InputEventHandler<T> | undefined;
|
|
2412
2239
|
onBeforeInputCapture?: FormEventHandler<T> | undefined;
|
|
2413
2240
|
onInput?: FormEventHandler<T> | undefined;
|
|
2414
2241
|
onInputCapture?: FormEventHandler<T> | undefined;
|
|
@@ -2428,9 +2255,9 @@ declare namespace React {
|
|
|
2428
2255
|
// Keyboard Events
|
|
2429
2256
|
onKeyDown?: KeyboardEventHandler<T> | undefined;
|
|
2430
2257
|
onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
|
|
2431
|
-
/** @deprecated */
|
|
2258
|
+
/** @deprecated Use `onKeyUp` or `onKeyDown` instead */
|
|
2432
2259
|
onKeyPress?: KeyboardEventHandler<T> | undefined;
|
|
2433
|
-
/** @deprecated */
|
|
2260
|
+
/** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
|
|
2434
2261
|
onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
|
|
2435
2262
|
onKeyUp?: KeyboardEventHandler<T> | undefined;
|
|
2436
2263
|
onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
|
|
@@ -2466,8 +2293,6 @@ declare namespace React {
|
|
|
2466
2293
|
onProgressCapture?: ReactEventHandler<T> | undefined;
|
|
2467
2294
|
onRateChange?: ReactEventHandler<T> | undefined;
|
|
2468
2295
|
onRateChangeCapture?: ReactEventHandler<T> | undefined;
|
|
2469
|
-
onResize?: ReactEventHandler<T> | undefined;
|
|
2470
|
-
onResizeCapture?: ReactEventHandler<T> | undefined;
|
|
2471
2296
|
onSeeked?: ReactEventHandler<T> | undefined;
|
|
2472
2297
|
onSeekedCapture?: ReactEventHandler<T> | undefined;
|
|
2473
2298
|
onSeeking?: ReactEventHandler<T> | undefined;
|
|
@@ -2558,6 +2383,8 @@ declare namespace React {
|
|
|
2558
2383
|
// UI Events
|
|
2559
2384
|
onScroll?: UIEventHandler<T> | undefined;
|
|
2560
2385
|
onScrollCapture?: UIEventHandler<T> | undefined;
|
|
2386
|
+
onScrollEnd?: UIEventHandler<T> | undefined;
|
|
2387
|
+
onScrollEndCapture?: UIEventHandler<T> | undefined;
|
|
2561
2388
|
|
|
2562
2389
|
// Wheel Events
|
|
2563
2390
|
onWheel?: WheelEventHandler<T> | undefined;
|
|
@@ -2571,9 +2398,19 @@ declare namespace React {
|
|
|
2571
2398
|
onAnimationIteration?: AnimationEventHandler<T> | undefined;
|
|
2572
2399
|
onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
|
|
2573
2400
|
|
|
2401
|
+
// Toggle Events
|
|
2402
|
+
onToggle?: ToggleEventHandler<T> | undefined;
|
|
2403
|
+
onBeforeToggle?: ToggleEventHandler<T> | undefined;
|
|
2404
|
+
|
|
2574
2405
|
// Transition Events
|
|
2406
|
+
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
|
2407
|
+
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
|
2575
2408
|
onTransitionEnd?: TransitionEventHandler<T> | undefined;
|
|
2576
2409
|
onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
|
|
2410
|
+
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
|
2411
|
+
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
|
2412
|
+
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
|
2413
|
+
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
|
2577
2414
|
}
|
|
2578
2415
|
|
|
2579
2416
|
export interface CSSProperties extends CSS.Properties<string | number> {
|
|
@@ -2893,12 +2730,14 @@ declare namespace React {
|
|
|
2893
2730
|
|
|
2894
2731
|
// Standard HTML Attributes
|
|
2895
2732
|
accessKey?: string | undefined;
|
|
2733
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
|
|
2896
2734
|
autoFocus?: boolean | undefined;
|
|
2897
2735
|
className?: string | undefined;
|
|
2898
2736
|
contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
|
|
2899
2737
|
contextMenu?: string | undefined;
|
|
2900
2738
|
dir?: string | undefined;
|
|
2901
2739
|
draggable?: Booleanish | undefined;
|
|
2740
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
2902
2741
|
hidden?: boolean | undefined;
|
|
2903
2742
|
id?: string | undefined;
|
|
2904
2743
|
lang?: string | undefined;
|
|
@@ -2930,7 +2769,6 @@ declare namespace React {
|
|
|
2930
2769
|
vocab?: string | undefined;
|
|
2931
2770
|
|
|
2932
2771
|
// Non-standard Attributes
|
|
2933
|
-
autoCapitalize?: string | undefined;
|
|
2934
2772
|
autoCorrect?: string | undefined;
|
|
2935
2773
|
autoSave?: string | undefined;
|
|
2936
2774
|
color?: string | undefined;
|
|
@@ -2943,7 +2781,16 @@ declare namespace React {
|
|
|
2943
2781
|
security?: string | undefined;
|
|
2944
2782
|
unselectable?: "on" | "off" | undefined;
|
|
2945
2783
|
|
|
2784
|
+
// Popover API
|
|
2785
|
+
popover?: "" | "auto" | "manual" | "hint" | undefined;
|
|
2786
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
|
|
2787
|
+
popoverTarget?: string | undefined;
|
|
2788
|
+
|
|
2946
2789
|
// Living Standard
|
|
2790
|
+
/**
|
|
2791
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
|
2792
|
+
*/
|
|
2793
|
+
inert?: boolean | undefined;
|
|
2947
2794
|
/**
|
|
2948
2795
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
|
2949
2796
|
* @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
|
|
@@ -2954,6 +2801,14 @@ declare namespace React {
|
|
|
2954
2801
|
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
|
|
2955
2802
|
*/
|
|
2956
2803
|
is?: string | undefined;
|
|
2804
|
+
/**
|
|
2805
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
|
|
2806
|
+
*/
|
|
2807
|
+
exportparts?: string | undefined;
|
|
2808
|
+
/**
|
|
2809
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
|
|
2810
|
+
*/
|
|
2811
|
+
part?: string | undefined;
|
|
2957
2812
|
}
|
|
2958
2813
|
|
|
2959
2814
|
/**
|
|
@@ -2970,6 +2825,7 @@ declare namespace React {
|
|
|
2970
2825
|
action?:
|
|
2971
2826
|
| string
|
|
2972
2827
|
| undefined
|
|
2828
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
2973
2829
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
2974
2830
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
2975
2831
|
];
|
|
@@ -3004,6 +2860,7 @@ declare namespace React {
|
|
|
3004
2860
|
formAction?:
|
|
3005
2861
|
| string
|
|
3006
2862
|
| undefined
|
|
2863
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3007
2864
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3008
2865
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3009
2866
|
];
|
|
@@ -3136,6 +2993,7 @@ declare namespace React {
|
|
|
3136
2993
|
form?: string | undefined;
|
|
3137
2994
|
formAction?:
|
|
3138
2995
|
| string
|
|
2996
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3139
2997
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3140
2998
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3141
2999
|
]
|
|
@@ -3169,7 +3027,6 @@ declare namespace React {
|
|
|
3169
3027
|
|
|
3170
3028
|
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3171
3029
|
open?: boolean | undefined;
|
|
3172
|
-
onToggle?: ReactEventHandler<T> | undefined;
|
|
3173
3030
|
name?: string | undefined;
|
|
3174
3031
|
}
|
|
3175
3032
|
|
|
@@ -3202,6 +3059,7 @@ declare namespace React {
|
|
|
3202
3059
|
action?:
|
|
3203
3060
|
| string
|
|
3204
3061
|
| undefined
|
|
3062
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3205
3063
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3206
3064
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3207
3065
|
];
|
|
@@ -3240,6 +3098,8 @@ declare namespace React {
|
|
|
3240
3098
|
width?: number | string | undefined;
|
|
3241
3099
|
}
|
|
3242
3100
|
|
|
3101
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {}
|
|
3102
|
+
|
|
3243
3103
|
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3244
3104
|
alt?: string | undefined;
|
|
3245
3105
|
crossOrigin?: CrossOrigin;
|
|
@@ -3249,7 +3109,12 @@ declare namespace React {
|
|
|
3249
3109
|
loading?: "eager" | "lazy" | undefined;
|
|
3250
3110
|
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
3251
3111
|
sizes?: string | undefined;
|
|
3252
|
-
src?:
|
|
3112
|
+
src?:
|
|
3113
|
+
| string
|
|
3114
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES[
|
|
3115
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES
|
|
3116
|
+
]
|
|
3117
|
+
| undefined;
|
|
3253
3118
|
srcSet?: string | undefined;
|
|
3254
3119
|
useMap?: string | undefined;
|
|
3255
3120
|
width?: number | string | undefined;
|
|
@@ -3354,10 +3219,10 @@ declare namespace React {
|
|
|
3354
3219
|
capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
|
|
3355
3220
|
checked?: boolean | undefined;
|
|
3356
3221
|
disabled?: boolean | undefined;
|
|
3357
|
-
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
3358
3222
|
form?: string | undefined;
|
|
3359
3223
|
formAction?:
|
|
3360
3224
|
| string
|
|
3225
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3361
3226
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3362
3227
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3363
3228
|
]
|
|
@@ -3408,6 +3273,7 @@ declare namespace React {
|
|
|
3408
3273
|
|
|
3409
3274
|
interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3410
3275
|
as?: string | undefined;
|
|
3276
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3411
3277
|
crossOrigin?: CrossOrigin;
|
|
3412
3278
|
fetchPriority?: "high" | "low" | "auto";
|
|
3413
3279
|
href?: string | undefined;
|
|
@@ -3420,6 +3286,9 @@ declare namespace React {
|
|
|
3420
3286
|
sizes?: string | undefined;
|
|
3421
3287
|
type?: string | undefined;
|
|
3422
3288
|
charSet?: string | undefined;
|
|
3289
|
+
|
|
3290
|
+
// React props
|
|
3291
|
+
precedence?: string | undefined;
|
|
3423
3292
|
}
|
|
3424
3293
|
|
|
3425
3294
|
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3430,6 +3299,8 @@ declare namespace React {
|
|
|
3430
3299
|
type?: string | undefined;
|
|
3431
3300
|
}
|
|
3432
3301
|
|
|
3302
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {}
|
|
3303
|
+
|
|
3433
3304
|
interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3434
3305
|
autoPlay?: boolean | undefined;
|
|
3435
3306
|
controls?: boolean | undefined;
|
|
@@ -3440,7 +3311,12 @@ declare namespace React {
|
|
|
3440
3311
|
muted?: boolean | undefined;
|
|
3441
3312
|
playsInline?: boolean | undefined;
|
|
3442
3313
|
preload?: string | undefined;
|
|
3443
|
-
src?:
|
|
3314
|
+
src?:
|
|
3315
|
+
| string
|
|
3316
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES[
|
|
3317
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES
|
|
3318
|
+
]
|
|
3319
|
+
| undefined;
|
|
3444
3320
|
}
|
|
3445
3321
|
|
|
3446
3322
|
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3517,10 +3393,12 @@ declare namespace React {
|
|
|
3517
3393
|
|
|
3518
3394
|
interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3519
3395
|
async?: boolean | undefined;
|
|
3396
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3520
3397
|
/** @deprecated */
|
|
3521
3398
|
charSet?: string | undefined;
|
|
3522
3399
|
crossOrigin?: CrossOrigin;
|
|
3523
3400
|
defer?: boolean | undefined;
|
|
3401
|
+
fetchPriority?: "high" | "low" | "auto" | undefined;
|
|
3524
3402
|
integrity?: string | undefined;
|
|
3525
3403
|
noModule?: boolean | undefined;
|
|
3526
3404
|
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
@@ -3551,9 +3429,14 @@ declare namespace React {
|
|
|
3551
3429
|
}
|
|
3552
3430
|
|
|
3553
3431
|
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3432
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3554
3433
|
media?: string | undefined;
|
|
3555
3434
|
scoped?: boolean | undefined;
|
|
3556
3435
|
type?: string | undefined;
|
|
3436
|
+
|
|
3437
|
+
// React props
|
|
3438
|
+
href?: string | undefined;
|
|
3439
|
+
precedence?: string | undefined;
|
|
3557
3440
|
}
|
|
3558
3441
|
|
|
3559
3442
|
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3627,6 +3510,9 @@ declare namespace React {
|
|
|
3627
3510
|
width?: number | string | undefined;
|
|
3628
3511
|
disablePictureInPicture?: boolean | undefined;
|
|
3629
3512
|
disableRemotePlayback?: boolean | undefined;
|
|
3513
|
+
|
|
3514
|
+
onResize?: ReactEventHandler<T> | undefined;
|
|
3515
|
+
onResizeCapture?: ReactEventHandler<T> | undefined;
|
|
3630
3516
|
}
|
|
3631
3517
|
|
|
3632
3518
|
// this list is "complete" in that it contains every SVG attribute
|
|
@@ -3720,7 +3606,21 @@ declare namespace React {
|
|
|
3720
3606
|
direction?: number | string | undefined;
|
|
3721
3607
|
display?: number | string | undefined;
|
|
3722
3608
|
divisor?: number | string | undefined;
|
|
3723
|
-
dominantBaseline?:
|
|
3609
|
+
dominantBaseline?:
|
|
3610
|
+
| "auto"
|
|
3611
|
+
| "use-script"
|
|
3612
|
+
| "no-change"
|
|
3613
|
+
| "reset-size"
|
|
3614
|
+
| "ideographic"
|
|
3615
|
+
| "alphabetic"
|
|
3616
|
+
| "hanging"
|
|
3617
|
+
| "mathematical"
|
|
3618
|
+
| "central"
|
|
3619
|
+
| "middle"
|
|
3620
|
+
| "text-after-edge"
|
|
3621
|
+
| "text-before-edge"
|
|
3622
|
+
| "inherit"
|
|
3623
|
+
| undefined;
|
|
3724
3624
|
dur?: number | string | undefined;
|
|
3725
3625
|
dx?: number | string | undefined;
|
|
3726
3626
|
dy?: number | string | undefined;
|
|
@@ -3867,7 +3767,7 @@ declare namespace React {
|
|
|
3867
3767
|
tableValues?: number | string | undefined;
|
|
3868
3768
|
targetX?: number | string | undefined;
|
|
3869
3769
|
targetY?: number | string | undefined;
|
|
3870
|
-
textAnchor?:
|
|
3770
|
+
textAnchor?: "start" | "middle" | "end" | "inherit" | undefined;
|
|
3871
3771
|
textDecoration?: number | string | undefined;
|
|
3872
3772
|
textLength?: number | string | undefined;
|
|
3873
3773
|
textRendering?: number | string | undefined;
|
|
@@ -3941,259 +3841,184 @@ declare namespace React {
|
|
|
3941
3841
|
webpreferences?: string | undefined;
|
|
3942
3842
|
}
|
|
3943
3843
|
|
|
3944
|
-
//
|
|
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
|
-
tspan: SVGFactory;
|
|
4123
|
-
use: SVGFactory;
|
|
4124
|
-
view: SVGFactory;
|
|
4125
|
-
}
|
|
4126
|
-
|
|
4127
|
-
interface ReactDOM extends ReactHTML, ReactSVG {}
|
|
4128
|
-
|
|
4129
|
-
//
|
|
4130
|
-
// React.PropTypes
|
|
4131
|
-
// ----------------------------------------------------------------------
|
|
4132
|
-
|
|
4133
|
-
/**
|
|
4134
|
-
* @deprecated Use `Validator` from the ´prop-types` instead.
|
|
4135
|
-
*/
|
|
4136
|
-
type Validator<T> = PropTypes.Validator<T>;
|
|
4137
|
-
|
|
4138
|
-
/**
|
|
4139
|
-
* @deprecated Use `Requireable` from the ´prop-types` instead.
|
|
4140
|
-
*/
|
|
4141
|
-
type Requireable<T> = PropTypes.Requireable<T>;
|
|
4142
|
-
|
|
4143
|
-
/**
|
|
4144
|
-
* @deprecated Use `ValidationMap` from the ´prop-types` instead.
|
|
4145
|
-
*/
|
|
4146
|
-
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
|
4147
|
-
|
|
4148
|
-
/**
|
|
4149
|
-
* @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
|
|
4150
|
-
*/
|
|
4151
|
-
type WeakValidationMap<T> = {
|
|
4152
|
-
[K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
|
|
4153
|
-
: undefined extends T[K] ? Validator<T[K] | null | undefined>
|
|
4154
|
-
: Validator<T[K]>;
|
|
4155
|
-
};
|
|
4156
|
-
|
|
4157
|
-
/**
|
|
4158
|
-
* @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
|
|
4159
|
-
*/
|
|
4160
|
-
interface ReactPropTypes {
|
|
4161
|
-
any: typeof PropTypes.any;
|
|
4162
|
-
array: typeof PropTypes.array;
|
|
4163
|
-
bool: typeof PropTypes.bool;
|
|
4164
|
-
func: typeof PropTypes.func;
|
|
4165
|
-
number: typeof PropTypes.number;
|
|
4166
|
-
object: typeof PropTypes.object;
|
|
4167
|
-
string: typeof PropTypes.string;
|
|
4168
|
-
node: typeof PropTypes.node;
|
|
4169
|
-
element: typeof PropTypes.element;
|
|
4170
|
-
instanceOf: typeof PropTypes.instanceOf;
|
|
4171
|
-
oneOf: typeof PropTypes.oneOf;
|
|
4172
|
-
oneOfType: typeof PropTypes.oneOfType;
|
|
4173
|
-
arrayOf: typeof PropTypes.arrayOf;
|
|
4174
|
-
objectOf: typeof PropTypes.objectOf;
|
|
4175
|
-
shape: typeof PropTypes.shape;
|
|
4176
|
-
exact: typeof PropTypes.exact;
|
|
4177
|
-
}
|
|
4178
|
-
|
|
4179
|
-
//
|
|
4180
|
-
// React.Children
|
|
4181
|
-
// ----------------------------------------------------------------------
|
|
4182
|
-
|
|
4183
|
-
/**
|
|
4184
|
-
* @deprecated - Use `typeof React.Children` instead.
|
|
4185
|
-
*/
|
|
4186
|
-
// Sync with type of `const Children`.
|
|
4187
|
-
interface ReactChildren {
|
|
4188
|
-
map<T, C>(
|
|
4189
|
-
children: C | readonly C[],
|
|
4190
|
-
fn: (child: C, index: number) => T,
|
|
4191
|
-
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
|
4192
|
-
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
|
4193
|
-
count(children: any): number;
|
|
4194
|
-
only<C>(children: C): C extends any[] ? never : C;
|
|
4195
|
-
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
|
4196
|
-
}
|
|
3844
|
+
// TODO: Move to react-dom
|
|
3845
|
+
type HTMLElementType =
|
|
3846
|
+
| "a"
|
|
3847
|
+
| "abbr"
|
|
3848
|
+
| "address"
|
|
3849
|
+
| "area"
|
|
3850
|
+
| "article"
|
|
3851
|
+
| "aside"
|
|
3852
|
+
| "audio"
|
|
3853
|
+
| "b"
|
|
3854
|
+
| "base"
|
|
3855
|
+
| "bdi"
|
|
3856
|
+
| "bdo"
|
|
3857
|
+
| "big"
|
|
3858
|
+
| "blockquote"
|
|
3859
|
+
| "body"
|
|
3860
|
+
| "br"
|
|
3861
|
+
| "button"
|
|
3862
|
+
| "canvas"
|
|
3863
|
+
| "caption"
|
|
3864
|
+
| "center"
|
|
3865
|
+
| "cite"
|
|
3866
|
+
| "code"
|
|
3867
|
+
| "col"
|
|
3868
|
+
| "colgroup"
|
|
3869
|
+
| "data"
|
|
3870
|
+
| "datalist"
|
|
3871
|
+
| "dd"
|
|
3872
|
+
| "del"
|
|
3873
|
+
| "details"
|
|
3874
|
+
| "dfn"
|
|
3875
|
+
| "dialog"
|
|
3876
|
+
| "div"
|
|
3877
|
+
| "dl"
|
|
3878
|
+
| "dt"
|
|
3879
|
+
| "em"
|
|
3880
|
+
| "embed"
|
|
3881
|
+
| "fieldset"
|
|
3882
|
+
| "figcaption"
|
|
3883
|
+
| "figure"
|
|
3884
|
+
| "footer"
|
|
3885
|
+
| "form"
|
|
3886
|
+
| "h1"
|
|
3887
|
+
| "h2"
|
|
3888
|
+
| "h3"
|
|
3889
|
+
| "h4"
|
|
3890
|
+
| "h5"
|
|
3891
|
+
| "h6"
|
|
3892
|
+
| "head"
|
|
3893
|
+
| "header"
|
|
3894
|
+
| "hgroup"
|
|
3895
|
+
| "hr"
|
|
3896
|
+
| "html"
|
|
3897
|
+
| "i"
|
|
3898
|
+
| "iframe"
|
|
3899
|
+
| "img"
|
|
3900
|
+
| "input"
|
|
3901
|
+
| "ins"
|
|
3902
|
+
| "kbd"
|
|
3903
|
+
| "keygen"
|
|
3904
|
+
| "label"
|
|
3905
|
+
| "legend"
|
|
3906
|
+
| "li"
|
|
3907
|
+
| "link"
|
|
3908
|
+
| "main"
|
|
3909
|
+
| "map"
|
|
3910
|
+
| "mark"
|
|
3911
|
+
| "menu"
|
|
3912
|
+
| "menuitem"
|
|
3913
|
+
| "meta"
|
|
3914
|
+
| "meter"
|
|
3915
|
+
| "nav"
|
|
3916
|
+
| "noscript"
|
|
3917
|
+
| "object"
|
|
3918
|
+
| "ol"
|
|
3919
|
+
| "optgroup"
|
|
3920
|
+
| "option"
|
|
3921
|
+
| "output"
|
|
3922
|
+
| "p"
|
|
3923
|
+
| "param"
|
|
3924
|
+
| "picture"
|
|
3925
|
+
| "pre"
|
|
3926
|
+
| "progress"
|
|
3927
|
+
| "q"
|
|
3928
|
+
| "rp"
|
|
3929
|
+
| "rt"
|
|
3930
|
+
| "ruby"
|
|
3931
|
+
| "s"
|
|
3932
|
+
| "samp"
|
|
3933
|
+
| "search"
|
|
3934
|
+
| "slot"
|
|
3935
|
+
| "script"
|
|
3936
|
+
| "section"
|
|
3937
|
+
| "select"
|
|
3938
|
+
| "small"
|
|
3939
|
+
| "source"
|
|
3940
|
+
| "span"
|
|
3941
|
+
| "strong"
|
|
3942
|
+
| "style"
|
|
3943
|
+
| "sub"
|
|
3944
|
+
| "summary"
|
|
3945
|
+
| "sup"
|
|
3946
|
+
| "table"
|
|
3947
|
+
| "template"
|
|
3948
|
+
| "tbody"
|
|
3949
|
+
| "td"
|
|
3950
|
+
| "textarea"
|
|
3951
|
+
| "tfoot"
|
|
3952
|
+
| "th"
|
|
3953
|
+
| "thead"
|
|
3954
|
+
| "time"
|
|
3955
|
+
| "title"
|
|
3956
|
+
| "tr"
|
|
3957
|
+
| "track"
|
|
3958
|
+
| "u"
|
|
3959
|
+
| "ul"
|
|
3960
|
+
| "var"
|
|
3961
|
+
| "video"
|
|
3962
|
+
| "wbr"
|
|
3963
|
+
| "webview";
|
|
3964
|
+
|
|
3965
|
+
// TODO: Move to react-dom
|
|
3966
|
+
type SVGElementType =
|
|
3967
|
+
| "animate"
|
|
3968
|
+
| "circle"
|
|
3969
|
+
| "clipPath"
|
|
3970
|
+
| "defs"
|
|
3971
|
+
| "desc"
|
|
3972
|
+
| "ellipse"
|
|
3973
|
+
| "feBlend"
|
|
3974
|
+
| "feColorMatrix"
|
|
3975
|
+
| "feComponentTransfer"
|
|
3976
|
+
| "feComposite"
|
|
3977
|
+
| "feConvolveMatrix"
|
|
3978
|
+
| "feDiffuseLighting"
|
|
3979
|
+
| "feDisplacementMap"
|
|
3980
|
+
| "feDistantLight"
|
|
3981
|
+
| "feDropShadow"
|
|
3982
|
+
| "feFlood"
|
|
3983
|
+
| "feFuncA"
|
|
3984
|
+
| "feFuncB"
|
|
3985
|
+
| "feFuncG"
|
|
3986
|
+
| "feFuncR"
|
|
3987
|
+
| "feGaussianBlur"
|
|
3988
|
+
| "feImage"
|
|
3989
|
+
| "feMerge"
|
|
3990
|
+
| "feMergeNode"
|
|
3991
|
+
| "feMorphology"
|
|
3992
|
+
| "feOffset"
|
|
3993
|
+
| "fePointLight"
|
|
3994
|
+
| "feSpecularLighting"
|
|
3995
|
+
| "feSpotLight"
|
|
3996
|
+
| "feTile"
|
|
3997
|
+
| "feTurbulence"
|
|
3998
|
+
| "filter"
|
|
3999
|
+
| "foreignObject"
|
|
4000
|
+
| "g"
|
|
4001
|
+
| "image"
|
|
4002
|
+
| "line"
|
|
4003
|
+
| "linearGradient"
|
|
4004
|
+
| "marker"
|
|
4005
|
+
| "mask"
|
|
4006
|
+
| "metadata"
|
|
4007
|
+
| "path"
|
|
4008
|
+
| "pattern"
|
|
4009
|
+
| "polygon"
|
|
4010
|
+
| "polyline"
|
|
4011
|
+
| "radialGradient"
|
|
4012
|
+
| "rect"
|
|
4013
|
+
| "stop"
|
|
4014
|
+
| "svg"
|
|
4015
|
+
| "switch"
|
|
4016
|
+
| "symbol"
|
|
4017
|
+
| "text"
|
|
4018
|
+
| "textPath"
|
|
4019
|
+
| "tspan"
|
|
4020
|
+
| "use"
|
|
4021
|
+
| "view";
|
|
4197
4022
|
|
|
4198
4023
|
//
|
|
4199
4024
|
// Browser Interfaces
|
|
@@ -4235,68 +4060,6 @@ declare namespace React {
|
|
|
4235
4060
|
}
|
|
4236
4061
|
|
|
4237
4062
|
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
|
4238
|
-
namespace JSX {
|
|
4239
|
-
type ElementType = GlobalJSXElementType;
|
|
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
4063
|
namespace JSX {
|
|
4301
4064
|
// We don't just alias React.ElementType because React.ElementType
|
|
4302
4065
|
// historically does more than we need it to.
|
|
@@ -4520,18 +4283,18 @@ declare global {
|
|
|
4520
4283
|
}
|
|
4521
4284
|
}
|
|
4522
4285
|
|
|
4523
|
-
|
|
4524
|
-
// But we can't access global.JSX so we need to create these aliases instead.
|
|
4525
|
-
// Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
|
|
4526
|
-
type GlobalJSXElementType = JSX.ElementType;
|
|
4527
|
-
interface GlobalJSXElement extends JSX.Element {}
|
|
4528
|
-
interface GlobalJSXElementClass extends JSX.ElementClass {}
|
|
4529
|
-
interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
|
|
4530
|
-
interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
|
|
4531
|
-
|
|
4532
|
-
type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
|
|
4286
|
+
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
|
4533
4287
|
|
|
4534
|
-
|
|
4535
|
-
|
|
4288
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
|
4289
|
+
// Undeclared default props are augmented into the resulting allowable attributes
|
|
4290
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
|
4291
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
|
4292
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
|
4293
|
+
:
|
|
4294
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
|
4295
|
+
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
|
4296
|
+
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
|
4297
|
+
: never;
|
|
4536
4298
|
|
|
4537
|
-
|
|
4299
|
+
type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
|
|
4300
|
+
: P;
|