@types/react 18.3.1 → 19.1.10
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 +2 -127
- react/compiler-runtime.d.ts +4 -0
- react/experimental.d.ts +136 -15
- react/global.d.ts +6 -0
- react/index.d.ts +496 -781
- react/package.json +9 -9
- react/ts5.0/canary.d.ts +2 -127
- react/ts5.0/experimental.d.ts +136 -15
- react/ts5.0/global.d.ts +6 -0
- react/ts5.0/index.d.ts +493 -779
- react/ts5.0/v18/global.d.ts +161 -0
- react/ts5.0/v18/index.d.ts +4550 -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 +4537 -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}
|
|
1133
|
-
*/
|
|
1134
|
-
propTypes?: WeakValidationMap<P> | undefined;
|
|
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}
|
|
1055
|
+
* Ignored by React.
|
|
1056
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
|
1142
1057
|
*/
|
|
1143
|
-
|
|
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,46 +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];
|
|
1895
|
-
/**
|
|
1896
|
-
* An alternative to `useState`.
|
|
1897
|
-
*
|
|
1898
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
1899
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
1900
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
|
1901
|
-
*
|
|
1902
|
-
* @version 16.8.0
|
|
1903
|
-
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1904
|
-
*/
|
|
1905
|
-
// overload where dispatch could accept 0 arguments.
|
|
1906
|
-
function useReducer<R extends ReducerWithoutAction<any>>(
|
|
1907
|
-
reducer: R,
|
|
1908
|
-
initializerArg: ReducerStateWithoutAction<R>,
|
|
1909
|
-
initializer?: undefined,
|
|
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>>];
|
|
1697
|
+
function useReducer<S, A extends AnyActionArg>(
|
|
1698
|
+
reducer: (prevState: S, ...args: A) => S,
|
|
1699
|
+
initialState: S,
|
|
1700
|
+
): [S, ActionDispatch<A>];
|
|
1929
1701
|
/**
|
|
1930
1702
|
* An alternative to `useState`.
|
|
1931
1703
|
*
|
|
@@ -1936,37 +1708,11 @@ declare namespace React {
|
|
|
1936
1708
|
* @version 16.8.0
|
|
1937
1709
|
* @see {@link https://react.dev/reference/react/useReducer}
|
|
1938
1710
|
*/
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
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
|
|
@@ -2052,7 +1794,7 @@ declare namespace React {
|
|
|
2052
1794
|
*/
|
|
2053
1795
|
// A specific function type would not trigger implicit any.
|
|
2054
1796
|
// 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/
|
|
1797
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2056
1798
|
function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
|
|
2057
1799
|
/**
|
|
2058
1800
|
* `useMemo` will only recompute the memoized value when one of the `deps` has changed.
|
|
@@ -2075,8 +1817,7 @@ declare namespace React {
|
|
|
2075
1817
|
// it's just the function name without the "use" prefix.
|
|
2076
1818
|
function useDebugValue<T>(value: T, format?: (value: T) => any): void;
|
|
2077
1819
|
|
|
2078
|
-
|
|
2079
|
-
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
|
1820
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
|
|
2080
1821
|
// strange definition to allow vscode to show documentation on the invocation
|
|
2081
1822
|
export interface TransitionStartFunction {
|
|
2082
1823
|
/**
|
|
@@ -2084,7 +1825,7 @@ declare namespace React {
|
|
|
2084
1825
|
*
|
|
2085
1826
|
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
|
2086
1827
|
*
|
|
2087
|
-
* @param callback A
|
|
1828
|
+
* @param callback A function which causes state updates that can be deferred.
|
|
2088
1829
|
*/
|
|
2089
1830
|
(callback: TransitionFunction): void;
|
|
2090
1831
|
}
|
|
@@ -2098,10 +1839,11 @@ declare namespace React {
|
|
|
2098
1839
|
* A good example of this is a text input.
|
|
2099
1840
|
*
|
|
2100
1841
|
* @param value The value that is going to be deferred
|
|
1842
|
+
* @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
1843
|
*
|
|
2102
1844
|
* @see {@link https://react.dev/reference/react/useDeferredValue}
|
|
2103
1845
|
*/
|
|
2104
|
-
export function useDeferredValue<T>(value: T): T;
|
|
1846
|
+
export function useDeferredValue<T>(value: T, initialValue?: T): T;
|
|
2105
1847
|
|
|
2106
1848
|
/**
|
|
2107
1849
|
* Allows components to avoid undesirable loading states by waiting for content to load
|
|
@@ -2123,7 +1865,7 @@ declare namespace React {
|
|
|
2123
1865
|
/**
|
|
2124
1866
|
* Similar to `useTransition` but allows uses where hooks are not available.
|
|
2125
1867
|
*
|
|
2126
|
-
* @param callback A
|
|
1868
|
+
* @param callback A function which causes state updates that can be deferred.
|
|
2127
1869
|
*/
|
|
2128
1870
|
export function startTransition(scope: TransitionFunction): void;
|
|
2129
1871
|
|
|
@@ -2138,6 +1880,11 @@ declare namespace React {
|
|
|
2138
1880
|
*
|
|
2139
1881
|
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
|
2140
1882
|
*/
|
|
1883
|
+
// NOTES
|
|
1884
|
+
// - the order of these signatures matters - typescript will check the signatures in source order.
|
|
1885
|
+
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
|
|
1886
|
+
// `strictNullChecks: false`.
|
|
1887
|
+
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
|
|
2141
1888
|
// 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
1889
|
export function act(callback: () => VoidOrUndefinedOnly): void;
|
|
2143
1890
|
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
@@ -2165,6 +1912,39 @@ declare namespace React {
|
|
|
2165
1912
|
getServerSnapshot?: () => Snapshot,
|
|
2166
1913
|
): Snapshot;
|
|
2167
1914
|
|
|
1915
|
+
export function useOptimistic<State>(
|
|
1916
|
+
passthrough: State,
|
|
1917
|
+
): [State, (action: State | ((pendingState: State) => State)) => void];
|
|
1918
|
+
export function useOptimistic<State, Action>(
|
|
1919
|
+
passthrough: State,
|
|
1920
|
+
reducer: (state: State, action: Action) => State,
|
|
1921
|
+
): [State, (action: Action) => void];
|
|
1922
|
+
|
|
1923
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
|
1924
|
+
|
|
1925
|
+
export function use<T>(usable: Usable<T>): T;
|
|
1926
|
+
|
|
1927
|
+
export function useActionState<State>(
|
|
1928
|
+
action: (state: Awaited<State>) => State | Promise<State>,
|
|
1929
|
+
initialState: Awaited<State>,
|
|
1930
|
+
permalink?: string,
|
|
1931
|
+
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
|
1932
|
+
export function useActionState<State, Payload>(
|
|
1933
|
+
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
|
1934
|
+
initialState: Awaited<State>,
|
|
1935
|
+
permalink?: string,
|
|
1936
|
+
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
1937
|
+
|
|
1938
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
1939
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
|
1940
|
+
|
|
1941
|
+
/**
|
|
1942
|
+
* Warning: Only available in development builds.
|
|
1943
|
+
*
|
|
1944
|
+
* @see {@link https://react.dev/reference/react/captureOwnerStack Reference docs}
|
|
1945
|
+
*/
|
|
1946
|
+
function captureOwnerStack(): string | null;
|
|
1947
|
+
|
|
2168
1948
|
//
|
|
2169
1949
|
// Event System
|
|
2170
1950
|
// ----------------------------------------------------------------------
|
|
@@ -2237,6 +2017,10 @@ declare namespace React {
|
|
|
2237
2017
|
target: EventTarget & T;
|
|
2238
2018
|
}
|
|
2239
2019
|
|
|
2020
|
+
interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
|
|
2021
|
+
data: string;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2240
2024
|
export type ModifierKey =
|
|
2241
2025
|
| "Alt"
|
|
2242
2026
|
| "AltGraph"
|
|
@@ -2332,6 +2116,11 @@ declare namespace React {
|
|
|
2332
2116
|
pseudoElement: string;
|
|
2333
2117
|
}
|
|
2334
2118
|
|
|
2119
|
+
interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
|
|
2120
|
+
oldState: "closed" | "open";
|
|
2121
|
+
newState: "closed" | "open";
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2335
2124
|
interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
|
|
2336
2125
|
elapsedTime: number;
|
|
2337
2126
|
propertyName: string;
|
|
@@ -2352,6 +2141,7 @@ declare namespace React {
|
|
|
2352
2141
|
type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
|
|
2353
2142
|
type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
|
|
2354
2143
|
type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
|
|
2144
|
+
type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
|
|
2355
2145
|
type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
|
|
2356
2146
|
type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
|
|
2357
2147
|
type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
|
|
@@ -2359,6 +2149,7 @@ declare namespace React {
|
|
|
2359
2149
|
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
|
2360
2150
|
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
|
|
2361
2151
|
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
|
|
2152
|
+
type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
|
|
2362
2153
|
type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
|
|
2363
2154
|
|
|
2364
2155
|
//
|
|
@@ -2409,7 +2200,7 @@ declare namespace React {
|
|
|
2409
2200
|
// Form Events
|
|
2410
2201
|
onChange?: FormEventHandler<T> | undefined;
|
|
2411
2202
|
onChangeCapture?: FormEventHandler<T> | undefined;
|
|
2412
|
-
onBeforeInput?:
|
|
2203
|
+
onBeforeInput?: InputEventHandler<T> | undefined;
|
|
2413
2204
|
onBeforeInputCapture?: FormEventHandler<T> | undefined;
|
|
2414
2205
|
onInput?: FormEventHandler<T> | undefined;
|
|
2415
2206
|
onInputCapture?: FormEventHandler<T> | undefined;
|
|
@@ -2429,9 +2220,9 @@ declare namespace React {
|
|
|
2429
2220
|
// Keyboard Events
|
|
2430
2221
|
onKeyDown?: KeyboardEventHandler<T> | undefined;
|
|
2431
2222
|
onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
|
|
2432
|
-
/** @deprecated */
|
|
2223
|
+
/** @deprecated Use `onKeyUp` or `onKeyDown` instead */
|
|
2433
2224
|
onKeyPress?: KeyboardEventHandler<T> | undefined;
|
|
2434
|
-
/** @deprecated */
|
|
2225
|
+
/** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
|
|
2435
2226
|
onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
|
|
2436
2227
|
onKeyUp?: KeyboardEventHandler<T> | undefined;
|
|
2437
2228
|
onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
|
|
@@ -2467,8 +2258,6 @@ declare namespace React {
|
|
|
2467
2258
|
onProgressCapture?: ReactEventHandler<T> | undefined;
|
|
2468
2259
|
onRateChange?: ReactEventHandler<T> | undefined;
|
|
2469
2260
|
onRateChangeCapture?: ReactEventHandler<T> | undefined;
|
|
2470
|
-
onResize?: ReactEventHandler<T> | undefined;
|
|
2471
|
-
onResizeCapture?: ReactEventHandler<T> | undefined;
|
|
2472
2261
|
onSeeked?: ReactEventHandler<T> | undefined;
|
|
2473
2262
|
onSeekedCapture?: ReactEventHandler<T> | undefined;
|
|
2474
2263
|
onSeeking?: ReactEventHandler<T> | undefined;
|
|
@@ -2559,6 +2348,8 @@ declare namespace React {
|
|
|
2559
2348
|
// UI Events
|
|
2560
2349
|
onScroll?: UIEventHandler<T> | undefined;
|
|
2561
2350
|
onScrollCapture?: UIEventHandler<T> | undefined;
|
|
2351
|
+
onScrollEnd?: UIEventHandler<T> | undefined;
|
|
2352
|
+
onScrollEndCapture?: UIEventHandler<T> | undefined;
|
|
2562
2353
|
|
|
2563
2354
|
// Wheel Events
|
|
2564
2355
|
onWheel?: WheelEventHandler<T> | undefined;
|
|
@@ -2572,9 +2363,19 @@ declare namespace React {
|
|
|
2572
2363
|
onAnimationIteration?: AnimationEventHandler<T> | undefined;
|
|
2573
2364
|
onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
|
|
2574
2365
|
|
|
2366
|
+
// Toggle Events
|
|
2367
|
+
onToggle?: ToggleEventHandler<T> | undefined;
|
|
2368
|
+
onBeforeToggle?: ToggleEventHandler<T> | undefined;
|
|
2369
|
+
|
|
2575
2370
|
// Transition Events
|
|
2371
|
+
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
|
2372
|
+
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
|
2576
2373
|
onTransitionEnd?: TransitionEventHandler<T> | undefined;
|
|
2577
2374
|
onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
|
|
2375
|
+
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
|
2376
|
+
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
|
2377
|
+
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
|
2378
|
+
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
|
2578
2379
|
}
|
|
2579
2380
|
|
|
2580
2381
|
export interface CSSProperties extends CSS.Properties<string | number> {
|
|
@@ -2894,12 +2695,14 @@ declare namespace React {
|
|
|
2894
2695
|
|
|
2895
2696
|
// Standard HTML Attributes
|
|
2896
2697
|
accessKey?: string | undefined;
|
|
2698
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
|
|
2897
2699
|
autoFocus?: boolean | undefined;
|
|
2898
2700
|
className?: string | undefined;
|
|
2899
2701
|
contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
|
|
2900
2702
|
contextMenu?: string | undefined;
|
|
2901
2703
|
dir?: string | undefined;
|
|
2902
2704
|
draggable?: Booleanish | undefined;
|
|
2705
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
2903
2706
|
hidden?: boolean | undefined;
|
|
2904
2707
|
id?: string | undefined;
|
|
2905
2708
|
lang?: string | undefined;
|
|
@@ -2931,7 +2734,6 @@ declare namespace React {
|
|
|
2931
2734
|
vocab?: string | undefined;
|
|
2932
2735
|
|
|
2933
2736
|
// Non-standard Attributes
|
|
2934
|
-
autoCapitalize?: string | undefined;
|
|
2935
2737
|
autoCorrect?: string | undefined;
|
|
2936
2738
|
autoSave?: string | undefined;
|
|
2937
2739
|
color?: string | undefined;
|
|
@@ -2944,7 +2746,16 @@ declare namespace React {
|
|
|
2944
2746
|
security?: string | undefined;
|
|
2945
2747
|
unselectable?: "on" | "off" | undefined;
|
|
2946
2748
|
|
|
2749
|
+
// Popover API
|
|
2750
|
+
popover?: "" | "auto" | "manual" | undefined;
|
|
2751
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
|
|
2752
|
+
popoverTarget?: string | undefined;
|
|
2753
|
+
|
|
2947
2754
|
// Living Standard
|
|
2755
|
+
/**
|
|
2756
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
|
2757
|
+
*/
|
|
2758
|
+
inert?: boolean | undefined;
|
|
2948
2759
|
/**
|
|
2949
2760
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
|
2950
2761
|
* @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
|
|
@@ -2955,6 +2766,14 @@ declare namespace React {
|
|
|
2955
2766
|
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
|
|
2956
2767
|
*/
|
|
2957
2768
|
is?: string | undefined;
|
|
2769
|
+
/**
|
|
2770
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
|
|
2771
|
+
*/
|
|
2772
|
+
exportparts?: string | undefined;
|
|
2773
|
+
/**
|
|
2774
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
|
|
2775
|
+
*/
|
|
2776
|
+
part?: string | undefined;
|
|
2958
2777
|
}
|
|
2959
2778
|
|
|
2960
2779
|
/**
|
|
@@ -2971,6 +2790,7 @@ declare namespace React {
|
|
|
2971
2790
|
action?:
|
|
2972
2791
|
| string
|
|
2973
2792
|
| undefined
|
|
2793
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
2974
2794
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
2975
2795
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
2976
2796
|
];
|
|
@@ -3005,6 +2825,7 @@ declare namespace React {
|
|
|
3005
2825
|
formAction?:
|
|
3006
2826
|
| string
|
|
3007
2827
|
| undefined
|
|
2828
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3008
2829
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3009
2830
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3010
2831
|
];
|
|
@@ -3137,6 +2958,7 @@ declare namespace React {
|
|
|
3137
2958
|
form?: string | undefined;
|
|
3138
2959
|
formAction?:
|
|
3139
2960
|
| string
|
|
2961
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3140
2962
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3141
2963
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3142
2964
|
]
|
|
@@ -3170,7 +2992,6 @@ declare namespace React {
|
|
|
3170
2992
|
|
|
3171
2993
|
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3172
2994
|
open?: boolean | undefined;
|
|
3173
|
-
onToggle?: ReactEventHandler<T> | undefined;
|
|
3174
2995
|
name?: string | undefined;
|
|
3175
2996
|
}
|
|
3176
2997
|
|
|
@@ -3203,6 +3024,7 @@ declare namespace React {
|
|
|
3203
3024
|
action?:
|
|
3204
3025
|
| string
|
|
3205
3026
|
| undefined
|
|
3027
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3206
3028
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3207
3029
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3208
3030
|
];
|
|
@@ -3241,6 +3063,8 @@ declare namespace React {
|
|
|
3241
3063
|
width?: number | string | undefined;
|
|
3242
3064
|
}
|
|
3243
3065
|
|
|
3066
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {}
|
|
3067
|
+
|
|
3244
3068
|
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3245
3069
|
alt?: string | undefined;
|
|
3246
3070
|
crossOrigin?: CrossOrigin;
|
|
@@ -3250,7 +3074,12 @@ declare namespace React {
|
|
|
3250
3074
|
loading?: "eager" | "lazy" | undefined;
|
|
3251
3075
|
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
3252
3076
|
sizes?: string | undefined;
|
|
3253
|
-
src?:
|
|
3077
|
+
src?:
|
|
3078
|
+
| string
|
|
3079
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES[
|
|
3080
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES
|
|
3081
|
+
]
|
|
3082
|
+
| undefined;
|
|
3254
3083
|
srcSet?: string | undefined;
|
|
3255
3084
|
useMap?: string | undefined;
|
|
3256
3085
|
width?: number | string | undefined;
|
|
@@ -3355,10 +3184,10 @@ declare namespace React {
|
|
|
3355
3184
|
capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
|
|
3356
3185
|
checked?: boolean | undefined;
|
|
3357
3186
|
disabled?: boolean | undefined;
|
|
3358
|
-
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
3359
3187
|
form?: string | undefined;
|
|
3360
3188
|
formAction?:
|
|
3361
3189
|
| string
|
|
3190
|
+
| ((formData: FormData) => void | Promise<void>)
|
|
3362
3191
|
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
|
3363
3192
|
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
|
3364
3193
|
]
|
|
@@ -3409,6 +3238,7 @@ declare namespace React {
|
|
|
3409
3238
|
|
|
3410
3239
|
interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3411
3240
|
as?: string | undefined;
|
|
3241
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3412
3242
|
crossOrigin?: CrossOrigin;
|
|
3413
3243
|
fetchPriority?: "high" | "low" | "auto";
|
|
3414
3244
|
href?: string | undefined;
|
|
@@ -3421,6 +3251,9 @@ declare namespace React {
|
|
|
3421
3251
|
sizes?: string | undefined;
|
|
3422
3252
|
type?: string | undefined;
|
|
3423
3253
|
charSet?: string | undefined;
|
|
3254
|
+
|
|
3255
|
+
// React props
|
|
3256
|
+
precedence?: string | undefined;
|
|
3424
3257
|
}
|
|
3425
3258
|
|
|
3426
3259
|
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3431,6 +3264,8 @@ declare namespace React {
|
|
|
3431
3264
|
type?: string | undefined;
|
|
3432
3265
|
}
|
|
3433
3266
|
|
|
3267
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {}
|
|
3268
|
+
|
|
3434
3269
|
interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3435
3270
|
autoPlay?: boolean | undefined;
|
|
3436
3271
|
controls?: boolean | undefined;
|
|
@@ -3441,7 +3276,12 @@ declare namespace React {
|
|
|
3441
3276
|
muted?: boolean | undefined;
|
|
3442
3277
|
playsInline?: boolean | undefined;
|
|
3443
3278
|
preload?: string | undefined;
|
|
3444
|
-
src?:
|
|
3279
|
+
src?:
|
|
3280
|
+
| string
|
|
3281
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES[
|
|
3282
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES
|
|
3283
|
+
]
|
|
3284
|
+
| undefined;
|
|
3445
3285
|
}
|
|
3446
3286
|
|
|
3447
3287
|
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3518,6 +3358,7 @@ declare namespace React {
|
|
|
3518
3358
|
|
|
3519
3359
|
interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3520
3360
|
async?: boolean | undefined;
|
|
3361
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3521
3362
|
/** @deprecated */
|
|
3522
3363
|
charSet?: string | undefined;
|
|
3523
3364
|
crossOrigin?: CrossOrigin;
|
|
@@ -3552,9 +3393,14 @@ declare namespace React {
|
|
|
3552
3393
|
}
|
|
3553
3394
|
|
|
3554
3395
|
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
3396
|
+
blocking?: "render" | (string & {}) | undefined;
|
|
3555
3397
|
media?: string | undefined;
|
|
3556
3398
|
scoped?: boolean | undefined;
|
|
3557
3399
|
type?: string | undefined;
|
|
3400
|
+
|
|
3401
|
+
// React props
|
|
3402
|
+
href?: string | undefined;
|
|
3403
|
+
precedence?: string | undefined;
|
|
3558
3404
|
}
|
|
3559
3405
|
|
|
3560
3406
|
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
@@ -3628,6 +3474,9 @@ declare namespace React {
|
|
|
3628
3474
|
width?: number | string | undefined;
|
|
3629
3475
|
disablePictureInPicture?: boolean | undefined;
|
|
3630
3476
|
disableRemotePlayback?: boolean | undefined;
|
|
3477
|
+
|
|
3478
|
+
onResize?: ReactEventHandler<T> | undefined;
|
|
3479
|
+
onResizeCapture?: ReactEventHandler<T> | undefined;
|
|
3631
3480
|
}
|
|
3632
3481
|
|
|
3633
3482
|
// this list is "complete" in that it contains every SVG attribute
|
|
@@ -3942,259 +3791,184 @@ declare namespace React {
|
|
|
3942
3791
|
webpreferences?: string | undefined;
|
|
3943
3792
|
}
|
|
3944
3793
|
|
|
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
|
-
}
|
|
3794
|
+
// TODO: Move to react-dom
|
|
3795
|
+
type HTMLElementType =
|
|
3796
|
+
| "a"
|
|
3797
|
+
| "abbr"
|
|
3798
|
+
| "address"
|
|
3799
|
+
| "area"
|
|
3800
|
+
| "article"
|
|
3801
|
+
| "aside"
|
|
3802
|
+
| "audio"
|
|
3803
|
+
| "b"
|
|
3804
|
+
| "base"
|
|
3805
|
+
| "bdi"
|
|
3806
|
+
| "bdo"
|
|
3807
|
+
| "big"
|
|
3808
|
+
| "blockquote"
|
|
3809
|
+
| "body"
|
|
3810
|
+
| "br"
|
|
3811
|
+
| "button"
|
|
3812
|
+
| "canvas"
|
|
3813
|
+
| "caption"
|
|
3814
|
+
| "center"
|
|
3815
|
+
| "cite"
|
|
3816
|
+
| "code"
|
|
3817
|
+
| "col"
|
|
3818
|
+
| "colgroup"
|
|
3819
|
+
| "data"
|
|
3820
|
+
| "datalist"
|
|
3821
|
+
| "dd"
|
|
3822
|
+
| "del"
|
|
3823
|
+
| "details"
|
|
3824
|
+
| "dfn"
|
|
3825
|
+
| "dialog"
|
|
3826
|
+
| "div"
|
|
3827
|
+
| "dl"
|
|
3828
|
+
| "dt"
|
|
3829
|
+
| "em"
|
|
3830
|
+
| "embed"
|
|
3831
|
+
| "fieldset"
|
|
3832
|
+
| "figcaption"
|
|
3833
|
+
| "figure"
|
|
3834
|
+
| "footer"
|
|
3835
|
+
| "form"
|
|
3836
|
+
| "h1"
|
|
3837
|
+
| "h2"
|
|
3838
|
+
| "h3"
|
|
3839
|
+
| "h4"
|
|
3840
|
+
| "h5"
|
|
3841
|
+
| "h6"
|
|
3842
|
+
| "head"
|
|
3843
|
+
| "header"
|
|
3844
|
+
| "hgroup"
|
|
3845
|
+
| "hr"
|
|
3846
|
+
| "html"
|
|
3847
|
+
| "i"
|
|
3848
|
+
| "iframe"
|
|
3849
|
+
| "img"
|
|
3850
|
+
| "input"
|
|
3851
|
+
| "ins"
|
|
3852
|
+
| "kbd"
|
|
3853
|
+
| "keygen"
|
|
3854
|
+
| "label"
|
|
3855
|
+
| "legend"
|
|
3856
|
+
| "li"
|
|
3857
|
+
| "link"
|
|
3858
|
+
| "main"
|
|
3859
|
+
| "map"
|
|
3860
|
+
| "mark"
|
|
3861
|
+
| "menu"
|
|
3862
|
+
| "menuitem"
|
|
3863
|
+
| "meta"
|
|
3864
|
+
| "meter"
|
|
3865
|
+
| "nav"
|
|
3866
|
+
| "noscript"
|
|
3867
|
+
| "object"
|
|
3868
|
+
| "ol"
|
|
3869
|
+
| "optgroup"
|
|
3870
|
+
| "option"
|
|
3871
|
+
| "output"
|
|
3872
|
+
| "p"
|
|
3873
|
+
| "param"
|
|
3874
|
+
| "picture"
|
|
3875
|
+
| "pre"
|
|
3876
|
+
| "progress"
|
|
3877
|
+
| "q"
|
|
3878
|
+
| "rp"
|
|
3879
|
+
| "rt"
|
|
3880
|
+
| "ruby"
|
|
3881
|
+
| "s"
|
|
3882
|
+
| "samp"
|
|
3883
|
+
| "search"
|
|
3884
|
+
| "slot"
|
|
3885
|
+
| "script"
|
|
3886
|
+
| "section"
|
|
3887
|
+
| "select"
|
|
3888
|
+
| "small"
|
|
3889
|
+
| "source"
|
|
3890
|
+
| "span"
|
|
3891
|
+
| "strong"
|
|
3892
|
+
| "style"
|
|
3893
|
+
| "sub"
|
|
3894
|
+
| "summary"
|
|
3895
|
+
| "sup"
|
|
3896
|
+
| "table"
|
|
3897
|
+
| "template"
|
|
3898
|
+
| "tbody"
|
|
3899
|
+
| "td"
|
|
3900
|
+
| "textarea"
|
|
3901
|
+
| "tfoot"
|
|
3902
|
+
| "th"
|
|
3903
|
+
| "thead"
|
|
3904
|
+
| "time"
|
|
3905
|
+
| "title"
|
|
3906
|
+
| "tr"
|
|
3907
|
+
| "track"
|
|
3908
|
+
| "u"
|
|
3909
|
+
| "ul"
|
|
3910
|
+
| "var"
|
|
3911
|
+
| "video"
|
|
3912
|
+
| "wbr"
|
|
3913
|
+
| "webview";
|
|
3914
|
+
|
|
3915
|
+
// TODO: Move to react-dom
|
|
3916
|
+
type SVGElementType =
|
|
3917
|
+
| "animate"
|
|
3918
|
+
| "circle"
|
|
3919
|
+
| "clipPath"
|
|
3920
|
+
| "defs"
|
|
3921
|
+
| "desc"
|
|
3922
|
+
| "ellipse"
|
|
3923
|
+
| "feBlend"
|
|
3924
|
+
| "feColorMatrix"
|
|
3925
|
+
| "feComponentTransfer"
|
|
3926
|
+
| "feComposite"
|
|
3927
|
+
| "feConvolveMatrix"
|
|
3928
|
+
| "feDiffuseLighting"
|
|
3929
|
+
| "feDisplacementMap"
|
|
3930
|
+
| "feDistantLight"
|
|
3931
|
+
| "feDropShadow"
|
|
3932
|
+
| "feFlood"
|
|
3933
|
+
| "feFuncA"
|
|
3934
|
+
| "feFuncB"
|
|
3935
|
+
| "feFuncG"
|
|
3936
|
+
| "feFuncR"
|
|
3937
|
+
| "feGaussianBlur"
|
|
3938
|
+
| "feImage"
|
|
3939
|
+
| "feMerge"
|
|
3940
|
+
| "feMergeNode"
|
|
3941
|
+
| "feMorphology"
|
|
3942
|
+
| "feOffset"
|
|
3943
|
+
| "fePointLight"
|
|
3944
|
+
| "feSpecularLighting"
|
|
3945
|
+
| "feSpotLight"
|
|
3946
|
+
| "feTile"
|
|
3947
|
+
| "feTurbulence"
|
|
3948
|
+
| "filter"
|
|
3949
|
+
| "foreignObject"
|
|
3950
|
+
| "g"
|
|
3951
|
+
| "image"
|
|
3952
|
+
| "line"
|
|
3953
|
+
| "linearGradient"
|
|
3954
|
+
| "marker"
|
|
3955
|
+
| "mask"
|
|
3956
|
+
| "metadata"
|
|
3957
|
+
| "path"
|
|
3958
|
+
| "pattern"
|
|
3959
|
+
| "polygon"
|
|
3960
|
+
| "polyline"
|
|
3961
|
+
| "radialGradient"
|
|
3962
|
+
| "rect"
|
|
3963
|
+
| "stop"
|
|
3964
|
+
| "svg"
|
|
3965
|
+
| "switch"
|
|
3966
|
+
| "symbol"
|
|
3967
|
+
| "text"
|
|
3968
|
+
| "textPath"
|
|
3969
|
+
| "tspan"
|
|
3970
|
+
| "use"
|
|
3971
|
+
| "view";
|
|
4198
3972
|
|
|
4199
3973
|
//
|
|
4200
3974
|
// Browser Interfaces
|
|
@@ -4236,67 +4010,6 @@ declare namespace React {
|
|
|
4236
4010
|
}
|
|
4237
4011
|
|
|
4238
4012
|
// 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
4013
|
namespace JSX {
|
|
4301
4014
|
interface Element extends React.ReactElement<any, any> {}
|
|
4302
4015
|
interface ElementClass extends React.Component<any> {
|
|
@@ -4508,17 +4221,18 @@ declare global {
|
|
|
4508
4221
|
}
|
|
4509
4222
|
}
|
|
4510
4223
|
|
|
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>;
|
|
4224
|
+
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
|
4520
4225
|
|
|
4521
|
-
|
|
4522
|
-
|
|
4226
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
|
4227
|
+
// Undeclared default props are augmented into the resulting allowable attributes
|
|
4228
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
|
4229
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
|
4230
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
|
4231
|
+
:
|
|
4232
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
|
4233
|
+
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
|
4234
|
+
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
|
4235
|
+
: never;
|
|
4523
4236
|
|
|
4524
|
-
|
|
4237
|
+
type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
|
|
4238
|
+
: P;
|