@types/react 17.0.65 → 17.0.67
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 v17.0/LICENSE +0 -0
- react v17.0/README.md +1 -1
- react v17.0/global.d.ts +142 -142
- react v17.0/index.d.ts +369 -297
- react v17.0/jsx-dev-runtime.d.ts +1 -1
- react v17.0/jsx-runtime.d.ts +1 -1
- react v17.0/package.json +3 -3
react v17.0/index.d.ts
CHANGED
@@ -31,9 +31,9 @@
|
|
31
31
|
|
32
32
|
/// <reference path="global.d.ts" />
|
33
33
|
|
34
|
-
import * as CSS from
|
35
|
-
import * as PropTypes from
|
36
|
-
import { Interaction as SchedulerInteraction } from
|
34
|
+
import * as CSS from "csstype";
|
35
|
+
import * as PropTypes from "prop-types";
|
36
|
+
import { Interaction as SchedulerInteraction } from "scheduler/tracing";
|
37
37
|
|
38
38
|
type NativeAnimationEvent = AnimationEvent;
|
39
39
|
type NativeClipboardEvent = ClipboardEvent;
|
@@ -47,8 +47,8 @@ type NativePointerEvent = PointerEvent;
|
|
47
47
|
type NativeTransitionEvent = TransitionEvent;
|
48
48
|
type NativeUIEvent = UIEvent;
|
49
49
|
type NativeWheelEvent = WheelEvent;
|
50
|
-
type Booleanish = boolean |
|
51
|
-
type CrossOrigin =
|
50
|
+
type Booleanish = boolean | "true" | "false";
|
51
|
+
type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
|
52
52
|
|
53
53
|
declare const UNDEFINED_VOID_ONLY: unique symbol;
|
54
54
|
// Destructors are only allowed to return void.
|
@@ -64,10 +64,10 @@ declare namespace React {
|
|
64
64
|
// ----------------------------------------------------------------------
|
65
65
|
|
66
66
|
type ElementType<P = any> =
|
67
|
-
{
|
68
|
-
[K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never
|
69
|
-
}[keyof JSX.IntrinsicElements]
|
70
|
-
ComponentType<P>;
|
67
|
+
| {
|
68
|
+
[K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never;
|
69
|
+
}[keyof JSX.IntrinsicElements]
|
70
|
+
| ComponentType<P>;
|
71
71
|
/**
|
72
72
|
* @deprecated Please use `ElementType`
|
73
73
|
*/
|
@@ -76,7 +76,7 @@ declare namespace React {
|
|
76
76
|
|
77
77
|
type JSXElementConstructor<P> =
|
78
78
|
| ((props: P) => ReactElement<any, any> | null)
|
79
|
-
| (new
|
79
|
+
| (new(props: P) => Component<any, any>);
|
80
80
|
|
81
81
|
interface RefObject<T> {
|
82
82
|
readonly current: T | null;
|
@@ -105,18 +105,16 @@ declare namespace React {
|
|
105
105
|
type ElementRef<
|
106
106
|
C extends
|
107
107
|
| ForwardRefExoticComponent<any>
|
108
|
-
| { new
|
108
|
+
| { new(props: any): Component<any> }
|
109
109
|
| ((props: any, context?: any) => ReactElement | null)
|
110
|
-
| keyof JSX.IntrinsicElements
|
110
|
+
| keyof JSX.IntrinsicElements,
|
111
111
|
> =
|
112
112
|
// need to check first if `ref` is a valid prop for ts@3.0
|
113
113
|
// otherwise it will infer `{}` instead of `never`
|
114
|
-
"ref" extends keyof ComponentPropsWithRef<C>
|
115
|
-
? NonNullable<ComponentPropsWithRef<C>["ref"]> extends Ref<
|
114
|
+
"ref" extends keyof ComponentPropsWithRef<C> ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends Ref<
|
116
115
|
infer Instance
|
117
|
-
>
|
118
|
-
|
119
|
-
: never
|
116
|
+
> ? Instance
|
117
|
+
: never
|
120
118
|
: never;
|
121
119
|
|
122
120
|
type ComponentState = any;
|
@@ -137,16 +135,19 @@ declare namespace React {
|
|
137
135
|
ref?: LegacyRef<T> | undefined;
|
138
136
|
}
|
139
137
|
|
140
|
-
interface ReactElement<
|
138
|
+
interface ReactElement<
|
139
|
+
P = any,
|
140
|
+
T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
|
141
|
+
> {
|
141
142
|
type: T;
|
142
143
|
props: P;
|
143
|
-
key:
|
144
|
+
key: string | null;
|
144
145
|
}
|
145
146
|
|
146
147
|
interface ReactComponentElement<
|
147
148
|
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
|
148
|
-
P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>,
|
149
|
-
> extends ReactElement<P, Exclude<T, number>> {
|
149
|
+
P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
|
150
|
+
> extends ReactElement<P, Exclude<T, number>> {}
|
150
151
|
|
151
152
|
/**
|
152
153
|
* @deprecated Please use `FunctionComponentElement`
|
@@ -154,7 +155,7 @@ declare namespace React {
|
|
154
155
|
type SFCElement<P> = FunctionComponentElement<P>;
|
155
156
|
|
156
157
|
interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
|
157
|
-
ref?: (
|
158
|
+
ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
|
158
159
|
}
|
159
160
|
|
160
161
|
type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
|
@@ -165,12 +166,14 @@ declare namespace React {
|
|
165
166
|
type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
|
166
167
|
|
167
168
|
// string fallback for custom web-components
|
168
|
-
interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
|
169
|
+
interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
|
170
|
+
extends ReactElement<P, string>
|
171
|
+
{
|
169
172
|
ref: LegacyRef<T>;
|
170
173
|
}
|
171
174
|
|
172
175
|
// ReactHTML for ReactHTMLElement
|
173
|
-
interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {
|
176
|
+
interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
|
174
177
|
|
175
178
|
interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
|
176
179
|
type: keyof ReactHTML;
|
@@ -182,7 +185,6 @@ declare namespace React {
|
|
182
185
|
}
|
183
186
|
|
184
187
|
interface ReactPortal extends ReactElement {
|
185
|
-
key: Key | null;
|
186
188
|
children: ReactNode;
|
187
189
|
}
|
188
190
|
|
@@ -197,16 +199,23 @@ declare namespace React {
|
|
197
199
|
*/
|
198
200
|
type SFCFactory<P> = FunctionComponentFactory<P>;
|
199
201
|
|
200
|
-
type FunctionComponentFactory<P> = (
|
202
|
+
type FunctionComponentFactory<P> = (
|
203
|
+
props?: Attributes & P,
|
204
|
+
...children: ReactNode[]
|
205
|
+
) => FunctionComponentElement<P>;
|
201
206
|
|
202
|
-
type ComponentFactory<P, T extends Component<P, ComponentState>> =
|
203
|
-
|
207
|
+
type ComponentFactory<P, T extends Component<P, ComponentState>> = (
|
208
|
+
props?: ClassAttributes<T> & P,
|
209
|
+
...children: ReactNode[]
|
210
|
+
) => CElement<P, T>;
|
204
211
|
|
205
212
|
type CFactory<P, T extends Component<P, ComponentState>> = ComponentFactory<P, T>;
|
206
213
|
type ClassicFactory<P> = CFactory<P, ClassicComponent<P, ComponentState>>;
|
207
214
|
|
208
|
-
type DOMFactory<P extends DOMAttributes<T>, T extends Element> =
|
209
|
-
|
215
|
+
type DOMFactory<P extends DOMAttributes<T>, T extends Element> = (
|
216
|
+
props?: ClassAttributes<T> & P | null,
|
217
|
+
...children: ReactNode[]
|
218
|
+
) => DOMElement<P, T>;
|
210
219
|
|
211
220
|
interface HTMLFactory<T extends HTMLElement> extends DetailedHTMLFactory<AllHTMLAttributes<T>, T> {}
|
212
221
|
|
@@ -215,7 +224,10 @@ declare namespace React {
|
|
215
224
|
}
|
216
225
|
|
217
226
|
interface SVGFactory extends DOMFactory<SVGAttributes<SVGElement>, SVGElement> {
|
218
|
-
(
|
227
|
+
(
|
228
|
+
props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null,
|
229
|
+
...children: ReactNode[]
|
230
|
+
): ReactSVGElement;
|
219
231
|
}
|
220
232
|
|
221
233
|
//
|
@@ -238,18 +250,23 @@ declare namespace React {
|
|
238
250
|
|
239
251
|
// DOM Elements
|
240
252
|
function createFactory<T extends HTMLElement>(
|
241
|
-
type: keyof ReactHTML
|
253
|
+
type: keyof ReactHTML,
|
254
|
+
): HTMLFactory<T>;
|
242
255
|
function createFactory(
|
243
|
-
type: keyof ReactSVG
|
256
|
+
type: keyof ReactSVG,
|
257
|
+
): SVGFactory;
|
244
258
|
function createFactory<P extends DOMAttributes<T>, T extends Element>(
|
245
|
-
type: string
|
259
|
+
type: string,
|
260
|
+
): DOMFactory<P, T>;
|
246
261
|
|
247
262
|
// Custom components
|
248
263
|
function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
|
249
264
|
function createFactory<P>(
|
250
|
-
type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P
|
265
|
+
type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P>>,
|
266
|
+
): CFactory<P, ClassicComponent<P, ComponentState>>;
|
251
267
|
function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
252
|
-
type: ClassType<P, T, C
|
268
|
+
type: ClassType<P, T, C>,
|
269
|
+
): CFactory<P, T>;
|
253
270
|
function createFactory<P>(type: ComponentClass<P>): Factory<P>;
|
254
271
|
|
255
272
|
// DOM Elements
|
@@ -257,74 +274,89 @@ declare namespace React {
|
|
257
274
|
function createElement(
|
258
275
|
type: "input",
|
259
276
|
props?: InputHTMLAttributes<HTMLInputElement> & ClassAttributes<HTMLInputElement> | null,
|
260
|
-
...children: ReactNode[]
|
277
|
+
...children: ReactNode[]
|
278
|
+
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
261
279
|
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
262
280
|
type: keyof ReactHTML,
|
263
281
|
props?: ClassAttributes<T> & P | null,
|
264
|
-
...children: ReactNode[]
|
282
|
+
...children: ReactNode[]
|
283
|
+
): DetailedReactHTMLElement<P, T>;
|
265
284
|
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
266
285
|
type: keyof ReactSVG,
|
267
286
|
props?: ClassAttributes<T> & P | null,
|
268
|
-
...children: ReactNode[]
|
287
|
+
...children: ReactNode[]
|
288
|
+
): ReactSVGElement;
|
269
289
|
function createElement<P extends DOMAttributes<T>, T extends Element>(
|
270
290
|
type: string,
|
271
291
|
props?: ClassAttributes<T> & P | null,
|
272
|
-
...children: ReactNode[]
|
292
|
+
...children: ReactNode[]
|
293
|
+
): DOMElement<P, T>;
|
273
294
|
|
274
295
|
// Custom components
|
275
296
|
|
276
297
|
function createElement<P extends {}>(
|
277
298
|
type: FunctionComponent<P>,
|
278
299
|
props?: Attributes & P | null,
|
279
|
-
...children: ReactNode[]
|
300
|
+
...children: ReactNode[]
|
301
|
+
): FunctionComponentElement<P>;
|
280
302
|
function createElement<P extends {}>(
|
281
303
|
type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P>>,
|
282
304
|
props?: ClassAttributes<ClassicComponent<P, ComponentState>> & P | null,
|
283
|
-
...children: ReactNode[]
|
305
|
+
...children: ReactNode[]
|
306
|
+
): CElement<P, ClassicComponent<P, ComponentState>>;
|
284
307
|
function createElement<P extends {}, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
285
308
|
type: ClassType<P, T, C>,
|
286
309
|
props?: ClassAttributes<T> & P | null,
|
287
|
-
...children: ReactNode[]
|
310
|
+
...children: ReactNode[]
|
311
|
+
): CElement<P, T>;
|
288
312
|
function createElement<P extends {}>(
|
289
313
|
type: FunctionComponent<P> | ComponentClass<P> | string,
|
290
314
|
props?: Attributes & P | null,
|
291
|
-
...children: ReactNode[]
|
315
|
+
...children: ReactNode[]
|
316
|
+
): ReactElement<P>;
|
292
317
|
|
293
318
|
// DOM Elements
|
294
319
|
// ReactHTMLElement
|
295
320
|
function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
296
321
|
element: DetailedReactHTMLElement<P, T>,
|
297
322
|
props?: P,
|
298
|
-
...children: ReactNode[]
|
323
|
+
...children: ReactNode[]
|
324
|
+
): DetailedReactHTMLElement<P, T>;
|
299
325
|
// ReactHTMLElement, less specific
|
300
326
|
function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
301
327
|
element: ReactHTMLElement<T>,
|
302
328
|
props?: P,
|
303
|
-
...children: ReactNode[]
|
329
|
+
...children: ReactNode[]
|
330
|
+
): ReactHTMLElement<T>;
|
304
331
|
// SVGElement
|
305
332
|
function cloneElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
306
333
|
element: ReactSVGElement,
|
307
334
|
props?: P,
|
308
|
-
...children: ReactNode[]
|
335
|
+
...children: ReactNode[]
|
336
|
+
): ReactSVGElement;
|
309
337
|
// DOM Element (has to be the last, because type checking stops at first overload that fits)
|
310
338
|
function cloneElement<P extends DOMAttributes<T>, T extends Element>(
|
311
339
|
element: DOMElement<P, T>,
|
312
340
|
props?: DOMAttributes<T> & P,
|
313
|
-
...children: ReactNode[]
|
341
|
+
...children: ReactNode[]
|
342
|
+
): DOMElement<P, T>;
|
314
343
|
|
315
344
|
// Custom components
|
316
345
|
function cloneElement<P>(
|
317
346
|
element: FunctionComponentElement<P>,
|
318
347
|
props?: Partial<P> & Attributes,
|
319
|
-
...children: ReactNode[]
|
348
|
+
...children: ReactNode[]
|
349
|
+
): FunctionComponentElement<P>;
|
320
350
|
function cloneElement<P, T extends Component<P, ComponentState>>(
|
321
351
|
element: CElement<P, T>,
|
322
352
|
props?: Partial<P> & ClassAttributes<T>,
|
323
|
-
...children: ReactNode[]
|
353
|
+
...children: ReactNode[]
|
354
|
+
): CElement<P, T>;
|
324
355
|
function cloneElement<P>(
|
325
356
|
element: ReactElement<P>,
|
326
357
|
props?: Partial<P> & Attributes,
|
327
|
-
...children: ReactNode[]
|
358
|
+
...children: ReactNode[]
|
359
|
+
): ReactElement<P>;
|
328
360
|
|
329
361
|
// Context via RenderProps
|
330
362
|
interface ProviderProps<T> {
|
@@ -350,7 +382,7 @@ declare namespace React {
|
|
350
382
|
/**
|
351
383
|
* **NOTE**: Exotic components are not callable.
|
352
384
|
*/
|
353
|
-
(props: P):
|
385
|
+
(props: P): ReactElement | null;
|
354
386
|
readonly $$typeof: symbol;
|
355
387
|
}
|
356
388
|
|
@@ -390,7 +422,7 @@ declare namespace React {
|
|
390
422
|
|
391
423
|
// TODO(react18): `fallback?: ReactNode;`
|
392
424
|
/** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
|
393
|
-
fallback: NonNullable<ReactNode
|
425
|
+
fallback: NonNullable<ReactNode> | null;
|
394
426
|
}
|
395
427
|
|
396
428
|
// TODO(react18): Updated JSDoc to reflect that Suspense works on the server.
|
@@ -428,7 +460,7 @@ declare namespace React {
|
|
428
460
|
type ReactInstance = Component<any> | Element;
|
429
461
|
|
430
462
|
// Base component for plain JS classes
|
431
|
-
interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
|
463
|
+
interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {}
|
432
464
|
class Component<P, S> {
|
433
465
|
// tslint won't let me format the sample code in a way that vscode likes it :(
|
434
466
|
/**
|
@@ -482,8 +514,8 @@ declare namespace React {
|
|
482
514
|
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
|
483
515
|
// Also, the ` | S` allows intellisense to not be dumbisense
|
484
516
|
setState<K extends keyof S>(
|
485
|
-
state: ((prevState: Readonly<S>, props: Readonly<P>) =>
|
486
|
-
callback?: () => void
|
517
|
+
state: ((prevState: Readonly<S>, props: Readonly<P>) => Pick<S, K> | S | null) | (Pick<S, K> | S | null),
|
518
|
+
callback?: () => void,
|
487
519
|
): void;
|
488
520
|
|
489
521
|
forceUpdate(callback?: () => void): void;
|
@@ -501,11 +533,11 @@ declare namespace React {
|
|
501
533
|
* https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs
|
502
534
|
*/
|
503
535
|
refs: {
|
504
|
-
[key: string]: ReactInstance
|
536
|
+
[key: string]: ReactInstance;
|
505
537
|
};
|
506
538
|
}
|
507
539
|
|
508
|
-
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {
|
540
|
+
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
|
509
541
|
|
510
542
|
interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
|
511
543
|
replaceState(nextState: S, callback?: () => void): void;
|
@@ -578,10 +610,10 @@ declare namespace React {
|
|
578
610
|
* @deprecated Use ForwardRefRenderFunction. forwardRef doesn't accept a
|
579
611
|
* "real" component.
|
580
612
|
*/
|
581
|
-
interface RefForwardingComponent
|
613
|
+
interface RefForwardingComponent<T, P = {}> extends ForwardRefRenderFunction<T, P> {}
|
582
614
|
|
583
615
|
interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
|
584
|
-
new
|
616
|
+
new(props: P, context?: any): Component<P, S>;
|
585
617
|
propTypes?: WeakValidationMap<P> | undefined;
|
586
618
|
contextType?: Context<any> | undefined;
|
587
619
|
contextTypes?: ValidationMap<any> | undefined;
|
@@ -591,7 +623,7 @@ declare namespace React {
|
|
591
623
|
}
|
592
624
|
|
593
625
|
interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
|
594
|
-
new
|
626
|
+
new(props: P, context?: any): ClassicComponent<P, ComponentState>;
|
595
627
|
getDefaultProps?(): P;
|
596
628
|
}
|
597
629
|
|
@@ -601,8 +633,8 @@ declare namespace React {
|
|
601
633
|
* See https://github.com/Microsoft/TypeScript/issues/7234 for more info.
|
602
634
|
*/
|
603
635
|
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
604
|
-
C
|
605
|
-
(new
|
636
|
+
& C
|
637
|
+
& (new(props: P, context?: any) => T);
|
606
638
|
|
607
639
|
//
|
608
640
|
// Component Specs and Lifecycle
|
@@ -800,23 +832,24 @@ declare namespace React {
|
|
800
832
|
propTypes?: WeakValidationMap<P> | undefined;
|
801
833
|
}
|
802
834
|
|
803
|
-
function forwardRef<T, P = {}>(
|
835
|
+
function forwardRef<T, P = {}>(
|
836
|
+
render: ForwardRefRenderFunction<T, P>,
|
837
|
+
): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
804
838
|
|
805
839
|
/** Ensures that the props do not include ref at all */
|
806
840
|
type PropsWithoutRef<P> =
|
807
841
|
// Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
|
808
842
|
// see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
809
843
|
// https://github.com/Microsoft/TypeScript/issues/28339
|
810
|
-
P extends any ? (
|
844
|
+
P extends any ? ("ref" extends keyof P ? Omit<P, "ref"> : P) : P;
|
811
845
|
/** Ensures that the props do not include string ref, which cannot be forwarded */
|
812
846
|
type PropsWithRef<P> =
|
813
847
|
// Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
|
814
|
-
|
848
|
+
"ref" extends keyof P
|
815
849
|
? P extends { ref?: infer R | undefined }
|
816
|
-
? string extends R
|
817
|
-
? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
818
|
-
: P
|
850
|
+
? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
819
851
|
: P
|
852
|
+
: P
|
820
853
|
: P;
|
821
854
|
|
822
855
|
type PropsWithChildren<P> = P & { children?: ReactNode | undefined };
|
@@ -825,26 +858,20 @@ declare namespace React {
|
|
825
858
|
* NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,
|
826
859
|
* or ComponentPropsWithoutRef when refs are not supported.
|
827
860
|
*/
|
828
|
-
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> =
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
|
837
|
-
: PropsWithRef<ComponentProps<T>>;
|
838
|
-
type ComponentPropsWithoutRef<T extends ElementType> =
|
839
|
-
PropsWithoutRef<ComponentProps<T>>;
|
861
|
+
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
862
|
+
JSXElementConstructor<infer P> ? P
|
863
|
+
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
864
|
+
: {};
|
865
|
+
type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
|
866
|
+
? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
|
867
|
+
: PropsWithRef<ComponentProps<T>>;
|
868
|
+
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
840
869
|
|
841
870
|
type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
|
842
871
|
ComponentPropsWithoutRef<T> & RefAttributes<infer Method>
|
843
|
-
>
|
844
|
-
? Method
|
845
|
-
:
|
846
|
-
? Method
|
847
|
-
: never;
|
872
|
+
> ? Method
|
873
|
+
: ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
874
|
+
: never;
|
848
875
|
|
849
876
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
850
877
|
// but can be given its own specific name
|
@@ -854,11 +881,14 @@ declare namespace React {
|
|
854
881
|
|
855
882
|
function memo<P extends object>(
|
856
883
|
Component: FunctionComponent<P>,
|
857
|
-
propsAreEqual?: (
|
884
|
+
propsAreEqual?: (
|
885
|
+
prevProps: Readonly<PropsWithChildren<P>>,
|
886
|
+
nextProps: Readonly<PropsWithChildren<P>>,
|
887
|
+
) => boolean,
|
858
888
|
): NamedExoticComponent<P>;
|
859
889
|
function memo<T extends ComponentType<any>>(
|
860
890
|
Component: T,
|
861
|
-
propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean
|
891
|
+
propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
|
862
892
|
): MemoExoticComponent<T>;
|
863
893
|
|
864
894
|
type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
|
@@ -866,7 +896,7 @@ declare namespace React {
|
|
866
896
|
};
|
867
897
|
|
868
898
|
function lazy<T extends ComponentType<any>>(
|
869
|
-
factory: () => Promise<{ default: T }
|
899
|
+
factory: () => Promise<{ default: T }>,
|
870
900
|
): LazyExoticComponent<T>;
|
871
901
|
|
872
902
|
//
|
@@ -891,13 +921,13 @@ declare namespace React {
|
|
891
921
|
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
892
922
|
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
893
923
|
// The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
|
894
|
-
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> =
|
895
|
-
|
924
|
+
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
|
925
|
+
: never;
|
896
926
|
// TODO (TypeScript 3.0): ReadonlyArray<unknown>
|
897
927
|
type DependencyList = ReadonlyArray<any>;
|
898
928
|
|
899
929
|
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
900
|
-
type EffectCallback = () =>
|
930
|
+
type EffectCallback = () => void | Destructor;
|
901
931
|
|
902
932
|
interface MutableRefObject<T> {
|
903
933
|
current: T;
|
@@ -911,7 +941,7 @@ declare namespace React {
|
|
911
941
|
* @version 16.8.0
|
912
942
|
* @see https://react.dev/reference/react/useContext
|
913
943
|
*/
|
914
|
-
function useContext<T>(context: Context<T
|
944
|
+
function useContext<T>(context: Context<T> /*, (not public API) observedBits?: number|boolean */): T;
|
915
945
|
/**
|
916
946
|
* Returns a stateful value, and a function to update it.
|
917
947
|
*
|
@@ -941,7 +971,7 @@ declare namespace React {
|
|
941
971
|
function useReducer<R extends ReducerWithoutAction<any>, I>(
|
942
972
|
reducer: R,
|
943
973
|
initializerArg: I,
|
944
|
-
initializer: (arg: I) => ReducerStateWithoutAction<R
|
974
|
+
initializer: (arg: I) => ReducerStateWithoutAction<R>,
|
945
975
|
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
946
976
|
/**
|
947
977
|
* An alternative to `useState`.
|
@@ -957,7 +987,7 @@ declare namespace React {
|
|
957
987
|
function useReducer<R extends ReducerWithoutAction<any>>(
|
958
988
|
reducer: R,
|
959
989
|
initializerArg: ReducerStateWithoutAction<R>,
|
960
|
-
initializer?: undefined
|
990
|
+
initializer?: undefined,
|
961
991
|
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
962
992
|
/**
|
963
993
|
* An alternative to `useState`.
|
@@ -975,7 +1005,7 @@ declare namespace React {
|
|
975
1005
|
function useReducer<R extends Reducer<any, any>, I>(
|
976
1006
|
reducer: R,
|
977
1007
|
initializerArg: I & ReducerState<R>,
|
978
|
-
initializer: (arg: I & ReducerState<R>) => ReducerState<R
|
1008
|
+
initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
|
979
1009
|
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
980
1010
|
/**
|
981
1011
|
* An alternative to `useState`.
|
@@ -991,7 +1021,7 @@ declare namespace React {
|
|
991
1021
|
function useReducer<R extends Reducer<any, any>, I>(
|
992
1022
|
reducer: R,
|
993
1023
|
initializerArg: I,
|
994
|
-
initializer: (arg: I) => ReducerState<R
|
1024
|
+
initializer: (arg: I) => ReducerState<R>,
|
995
1025
|
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
996
1026
|
/**
|
997
1027
|
* An alternative to `useState`.
|
@@ -1016,7 +1046,7 @@ declare namespace React {
|
|
1016
1046
|
function useReducer<R extends Reducer<any, any>>(
|
1017
1047
|
reducer: R,
|
1018
1048
|
initialState: ReducerState<R>,
|
1019
|
-
initializer?: undefined
|
1049
|
+
initializer?: undefined,
|
1020
1050
|
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1021
1051
|
/**
|
1022
1052
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
@@ -1043,7 +1073,7 @@ declare namespace React {
|
|
1043
1073
|
* @version 16.8.0
|
1044
1074
|
* @see https://react.dev/reference/react/useRef
|
1045
1075
|
*/
|
1046
|
-
function useRef<T>(initialValue: T|null): RefObject<T>;
|
1076
|
+
function useRef<T>(initialValue: T | null): RefObject<T>;
|
1047
1077
|
// convenience overload for potentially undefined initialValue / call with 0 arguments
|
1048
1078
|
// has a default to stop it from defaulting to {} instead
|
1049
1079
|
/**
|
@@ -1091,7 +1121,7 @@ declare namespace React {
|
|
1091
1121
|
* @version 16.8.0
|
1092
1122
|
* @see https://react.dev/reference/react/useImperativeHandle
|
1093
1123
|
*/
|
1094
|
-
function useImperativeHandle<T, R extends T>(ref: Ref<T
|
1124
|
+
function useImperativeHandle<T, R extends T>(ref: Ref<T> | undefined, init: () => R, deps?: DependencyList): void;
|
1095
1125
|
// I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key
|
1096
1126
|
// useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y.
|
1097
1127
|
/**
|
@@ -1176,7 +1206,7 @@ declare namespace React {
|
|
1176
1206
|
twist: number;
|
1177
1207
|
width: number;
|
1178
1208
|
height: number;
|
1179
|
-
pointerType:
|
1209
|
+
pointerType: "mouse" | "pen" | "touch";
|
1180
1210
|
isPrimary: boolean;
|
1181
1211
|
}
|
1182
1212
|
|
@@ -1196,7 +1226,21 @@ declare namespace React {
|
|
1196
1226
|
target: EventTarget & T;
|
1197
1227
|
}
|
1198
1228
|
|
1199
|
-
export type ModifierKey =
|
1229
|
+
export type ModifierKey =
|
1230
|
+
| "Alt"
|
1231
|
+
| "AltGraph"
|
1232
|
+
| "CapsLock"
|
1233
|
+
| "Control"
|
1234
|
+
| "Fn"
|
1235
|
+
| "FnLock"
|
1236
|
+
| "Hyper"
|
1237
|
+
| "Meta"
|
1238
|
+
| "NumLock"
|
1239
|
+
| "ScrollLock"
|
1240
|
+
| "Shift"
|
1241
|
+
| "Super"
|
1242
|
+
| "Symbol"
|
1243
|
+
| "SymbolLock";
|
1200
1244
|
|
1201
1245
|
interface KeyboardEvent<T = Element> extends UIEvent<T, NativeKeyboardEvent> {
|
1202
1246
|
altKey: boolean;
|
@@ -1556,262 +1600,273 @@ declare namespace React {
|
|
1556
1600
|
// All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
|
1557
1601
|
interface AriaAttributes {
|
1558
1602
|
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
|
1559
|
-
|
1603
|
+
"aria-activedescendant"?: string | undefined;
|
1560
1604
|
/** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
|
1561
|
-
|
1605
|
+
"aria-atomic"?: Booleanish | undefined;
|
1562
1606
|
/**
|
1563
1607
|
* Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
|
1564
1608
|
* presented if they are made.
|
1565
1609
|
*/
|
1566
|
-
|
1610
|
+
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
|
1567
1611
|
/** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */
|
1568
|
-
|
1612
|
+
"aria-busy"?: Booleanish | undefined;
|
1569
1613
|
/**
|
1570
1614
|
* Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
|
1571
1615
|
* @see aria-pressed @see aria-selected.
|
1572
1616
|
*/
|
1573
|
-
|
1617
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
1574
1618
|
/**
|
1575
1619
|
* Defines the total number of columns in a table, grid, or treegrid.
|
1576
1620
|
* @see aria-colindex.
|
1577
1621
|
*/
|
1578
|
-
|
1622
|
+
"aria-colcount"?: number | undefined;
|
1579
1623
|
/**
|
1580
1624
|
* Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
|
1581
1625
|
* @see aria-colcount @see aria-colspan.
|
1582
1626
|
*/
|
1583
|
-
|
1627
|
+
"aria-colindex"?: number | undefined;
|
1584
1628
|
/**
|
1585
1629
|
* Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
|
1586
1630
|
* @see aria-colindex @see aria-rowspan.
|
1587
1631
|
*/
|
1588
|
-
|
1632
|
+
"aria-colspan"?: number | undefined;
|
1589
1633
|
/**
|
1590
1634
|
* Identifies the element (or elements) whose contents or presence are controlled by the current element.
|
1591
1635
|
* @see aria-owns.
|
1592
1636
|
*/
|
1593
|
-
|
1637
|
+
"aria-controls"?: string | undefined;
|
1594
1638
|
/** Indicates the element that represents the current item within a container or set of related elements. */
|
1595
|
-
|
1639
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
1596
1640
|
/**
|
1597
1641
|
* Identifies the element (or elements) that describes the object.
|
1598
1642
|
* @see aria-labelledby
|
1599
1643
|
*/
|
1600
|
-
|
1644
|
+
"aria-describedby"?: string | undefined;
|
1601
1645
|
/**
|
1602
1646
|
* Identifies the element that provides a detailed, extended description for the object.
|
1603
1647
|
* @see aria-describedby.
|
1604
1648
|
*/
|
1605
|
-
|
1649
|
+
"aria-details"?: string | undefined;
|
1606
1650
|
/**
|
1607
1651
|
* Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
|
1608
1652
|
* @see aria-hidden @see aria-readonly.
|
1609
1653
|
*/
|
1610
|
-
|
1654
|
+
"aria-disabled"?: Booleanish | undefined;
|
1611
1655
|
/**
|
1612
1656
|
* Indicates what functions can be performed when a dragged object is released on the drop target.
|
1613
1657
|
* @deprecated in ARIA 1.1
|
1614
1658
|
*/
|
1615
|
-
|
1659
|
+
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
|
1616
1660
|
/**
|
1617
1661
|
* Identifies the element that provides an error message for the object.
|
1618
1662
|
* @see aria-invalid @see aria-describedby.
|
1619
1663
|
*/
|
1620
|
-
|
1664
|
+
"aria-errormessage"?: string | undefined;
|
1621
1665
|
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
|
1622
|
-
|
1666
|
+
"aria-expanded"?: Booleanish | undefined;
|
1623
1667
|
/**
|
1624
1668
|
* Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
|
1625
1669
|
* allows assistive technology to override the general default of reading in document source order.
|
1626
1670
|
*/
|
1627
|
-
|
1671
|
+
"aria-flowto"?: string | undefined;
|
1628
1672
|
/**
|
1629
1673
|
* Indicates an element's "grabbed" state in a drag-and-drop operation.
|
1630
1674
|
* @deprecated in ARIA 1.1
|
1631
1675
|
*/
|
1632
|
-
|
1676
|
+
"aria-grabbed"?: Booleanish | undefined;
|
1633
1677
|
/** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
|
1634
|
-
|
1678
|
+
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
|
1635
1679
|
/**
|
1636
1680
|
* Indicates whether the element is exposed to an accessibility API.
|
1637
1681
|
* @see aria-disabled.
|
1638
1682
|
*/
|
1639
|
-
|
1683
|
+
"aria-hidden"?: Booleanish | undefined;
|
1640
1684
|
/**
|
1641
1685
|
* Indicates the entered value does not conform to the format expected by the application.
|
1642
1686
|
* @see aria-errormessage.
|
1643
1687
|
*/
|
1644
|
-
|
1688
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
1645
1689
|
/** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
|
1646
|
-
|
1690
|
+
"aria-keyshortcuts"?: string | undefined;
|
1647
1691
|
/**
|
1648
1692
|
* Defines a string value that labels the current element.
|
1649
1693
|
* @see aria-labelledby.
|
1650
1694
|
*/
|
1651
|
-
|
1695
|
+
"aria-label"?: string | undefined;
|
1652
1696
|
/**
|
1653
1697
|
* Identifies the element (or elements) that labels the current element.
|
1654
1698
|
* @see aria-describedby.
|
1655
1699
|
*/
|
1656
|
-
|
1700
|
+
"aria-labelledby"?: string | undefined;
|
1657
1701
|
/** Defines the hierarchical level of an element within a structure. */
|
1658
|
-
|
1702
|
+
"aria-level"?: number | undefined;
|
1659
1703
|
/** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */
|
1660
|
-
|
1704
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
1661
1705
|
/** Indicates whether an element is modal when displayed. */
|
1662
|
-
|
1706
|
+
"aria-modal"?: Booleanish | undefined;
|
1663
1707
|
/** Indicates whether a text box accepts multiple lines of input or only a single line. */
|
1664
|
-
|
1708
|
+
"aria-multiline"?: Booleanish | undefined;
|
1665
1709
|
/** Indicates that the user may select more than one item from the current selectable descendants. */
|
1666
|
-
|
1710
|
+
"aria-multiselectable"?: Booleanish | undefined;
|
1667
1711
|
/** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
|
1668
|
-
|
1712
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
1669
1713
|
/**
|
1670
1714
|
* Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
|
1671
1715
|
* between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
|
1672
1716
|
* @see aria-controls.
|
1673
1717
|
*/
|
1674
|
-
|
1718
|
+
"aria-owns"?: string | undefined;
|
1675
1719
|
/**
|
1676
1720
|
* Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
|
1677
1721
|
* A hint could be a sample value or a brief description of the expected format.
|
1678
1722
|
*/
|
1679
|
-
|
1723
|
+
"aria-placeholder"?: string | undefined;
|
1680
1724
|
/**
|
1681
1725
|
* Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
|
1682
1726
|
* @see aria-setsize.
|
1683
1727
|
*/
|
1684
|
-
|
1728
|
+
"aria-posinset"?: number | undefined;
|
1685
1729
|
/**
|
1686
1730
|
* Indicates the current "pressed" state of toggle buttons.
|
1687
1731
|
* @see aria-checked @see aria-selected.
|
1688
1732
|
*/
|
1689
|
-
|
1733
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
1690
1734
|
/**
|
1691
1735
|
* Indicates that the element is not editable, but is otherwise operable.
|
1692
1736
|
* @see aria-disabled.
|
1693
1737
|
*/
|
1694
|
-
|
1738
|
+
"aria-readonly"?: Booleanish | undefined;
|
1695
1739
|
/**
|
1696
1740
|
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
|
1697
1741
|
* @see aria-atomic.
|
1698
1742
|
*/
|
1699
|
-
|
1743
|
+
"aria-relevant"?:
|
1744
|
+
| "additions"
|
1745
|
+
| "additions removals"
|
1746
|
+
| "additions text"
|
1747
|
+
| "all"
|
1748
|
+
| "removals"
|
1749
|
+
| "removals additions"
|
1750
|
+
| "removals text"
|
1751
|
+
| "text"
|
1752
|
+
| "text additions"
|
1753
|
+
| "text removals"
|
1754
|
+
| undefined;
|
1700
1755
|
/** Indicates that user input is required on the element before a form may be submitted. */
|
1701
|
-
|
1756
|
+
"aria-required"?: Booleanish | undefined;
|
1702
1757
|
/** Defines a human-readable, author-localized description for the role of an element. */
|
1703
|
-
|
1758
|
+
"aria-roledescription"?: string | undefined;
|
1704
1759
|
/**
|
1705
1760
|
* Defines the total number of rows in a table, grid, or treegrid.
|
1706
1761
|
* @see aria-rowindex.
|
1707
1762
|
*/
|
1708
|
-
|
1763
|
+
"aria-rowcount"?: number | undefined;
|
1709
1764
|
/**
|
1710
1765
|
* Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
|
1711
1766
|
* @see aria-rowcount @see aria-rowspan.
|
1712
1767
|
*/
|
1713
|
-
|
1768
|
+
"aria-rowindex"?: number | undefined;
|
1714
1769
|
/**
|
1715
1770
|
* Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
|
1716
1771
|
* @see aria-rowindex @see aria-colspan.
|
1717
1772
|
*/
|
1718
|
-
|
1773
|
+
"aria-rowspan"?: number | undefined;
|
1719
1774
|
/**
|
1720
1775
|
* Indicates the current "selected" state of various widgets.
|
1721
1776
|
* @see aria-checked @see aria-pressed.
|
1722
1777
|
*/
|
1723
|
-
|
1778
|
+
"aria-selected"?: Booleanish | undefined;
|
1724
1779
|
/**
|
1725
1780
|
* Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
|
1726
1781
|
* @see aria-posinset.
|
1727
1782
|
*/
|
1728
|
-
|
1783
|
+
"aria-setsize"?: number | undefined;
|
1729
1784
|
/** Indicates if items in a table or grid are sorted in ascending or descending order. */
|
1730
|
-
|
1785
|
+
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
1731
1786
|
/** Defines the maximum allowed value for a range widget. */
|
1732
|
-
|
1787
|
+
"aria-valuemax"?: number | undefined;
|
1733
1788
|
/** Defines the minimum allowed value for a range widget. */
|
1734
|
-
|
1789
|
+
"aria-valuemin"?: number | undefined;
|
1735
1790
|
/**
|
1736
1791
|
* Defines the current value for a range widget.
|
1737
1792
|
* @see aria-valuetext.
|
1738
1793
|
*/
|
1739
|
-
|
1794
|
+
"aria-valuenow"?: number | undefined;
|
1740
1795
|
/** Defines the human readable text alternative of aria-valuenow for a range widget. */
|
1741
|
-
|
1796
|
+
"aria-valuetext"?: string | undefined;
|
1742
1797
|
}
|
1743
1798
|
|
1744
1799
|
// All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
|
1745
1800
|
type AriaRole =
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1801
|
+
| "alert"
|
1802
|
+
| "alertdialog"
|
1803
|
+
| "application"
|
1804
|
+
| "article"
|
1805
|
+
| "banner"
|
1806
|
+
| "button"
|
1807
|
+
| "cell"
|
1808
|
+
| "checkbox"
|
1809
|
+
| "columnheader"
|
1810
|
+
| "combobox"
|
1811
|
+
| "complementary"
|
1812
|
+
| "contentinfo"
|
1813
|
+
| "definition"
|
1814
|
+
| "dialog"
|
1815
|
+
| "directory"
|
1816
|
+
| "document"
|
1817
|
+
| "feed"
|
1818
|
+
| "figure"
|
1819
|
+
| "form"
|
1820
|
+
| "grid"
|
1821
|
+
| "gridcell"
|
1822
|
+
| "group"
|
1823
|
+
| "heading"
|
1824
|
+
| "img"
|
1825
|
+
| "link"
|
1826
|
+
| "list"
|
1827
|
+
| "listbox"
|
1828
|
+
| "listitem"
|
1829
|
+
| "log"
|
1830
|
+
| "main"
|
1831
|
+
| "marquee"
|
1832
|
+
| "math"
|
1833
|
+
| "menu"
|
1834
|
+
| "menubar"
|
1835
|
+
| "menuitem"
|
1836
|
+
| "menuitemcheckbox"
|
1837
|
+
| "menuitemradio"
|
1838
|
+
| "navigation"
|
1839
|
+
| "none"
|
1840
|
+
| "note"
|
1841
|
+
| "option"
|
1842
|
+
| "presentation"
|
1843
|
+
| "progressbar"
|
1844
|
+
| "radio"
|
1845
|
+
| "radiogroup"
|
1846
|
+
| "region"
|
1847
|
+
| "row"
|
1848
|
+
| "rowgroup"
|
1849
|
+
| "rowheader"
|
1850
|
+
| "scrollbar"
|
1851
|
+
| "search"
|
1852
|
+
| "searchbox"
|
1853
|
+
| "separator"
|
1854
|
+
| "slider"
|
1855
|
+
| "spinbutton"
|
1856
|
+
| "status"
|
1857
|
+
| "switch"
|
1858
|
+
| "tab"
|
1859
|
+
| "table"
|
1860
|
+
| "tablist"
|
1861
|
+
| "tabpanel"
|
1862
|
+
| "term"
|
1863
|
+
| "textbox"
|
1864
|
+
| "timer"
|
1865
|
+
| "toolbar"
|
1866
|
+
| "tooltip"
|
1867
|
+
| "tree"
|
1868
|
+
| "treegrid"
|
1869
|
+
| "treeitem"
|
1815
1870
|
| (string & {});
|
1816
1871
|
|
1817
1872
|
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
@@ -1839,7 +1894,7 @@ declare namespace React {
|
|
1839
1894
|
style?: CSSProperties | undefined;
|
1840
1895
|
tabIndex?: number | undefined;
|
1841
1896
|
title?: string | undefined;
|
1842
|
-
translate?:
|
1897
|
+
translate?: "yes" | "no" | undefined;
|
1843
1898
|
|
1844
1899
|
// Unknown
|
1845
1900
|
radioGroup?: string | undefined; // <command>, <menuitem>
|
@@ -1872,14 +1927,14 @@ declare namespace React {
|
|
1872
1927
|
itemRef?: string | undefined;
|
1873
1928
|
results?: number | undefined;
|
1874
1929
|
security?: string | undefined;
|
1875
|
-
unselectable?:
|
1930
|
+
unselectable?: "on" | "off" | undefined;
|
1876
1931
|
|
1877
1932
|
// Living Standard
|
1878
1933
|
/**
|
1879
1934
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
1880
1935
|
* @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
|
1881
1936
|
*/
|
1882
|
-
inputMode?:
|
1937
|
+
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
|
1883
1938
|
/**
|
1884
1939
|
* Specify that a standard HTML element should behave like a defined custom built-in element
|
1885
1940
|
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
|
@@ -1899,7 +1954,7 @@ declare namespace React {
|
|
1899
1954
|
async?: boolean | undefined;
|
1900
1955
|
autoComplete?: string | undefined;
|
1901
1956
|
autoPlay?: boolean | undefined;
|
1902
|
-
capture?: boolean |
|
1957
|
+
capture?: boolean | "user" | "environment" | undefined;
|
1903
1958
|
cellPadding?: number | string | undefined;
|
1904
1959
|
cellSpacing?: number | string | undefined;
|
1905
1960
|
charSet?: string | undefined;
|
@@ -1994,21 +2049,21 @@ declare namespace React {
|
|
1994
2049
|
}
|
1995
2050
|
|
1996
2051
|
type HTMLAttributeReferrerPolicy =
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2052
|
+
| ""
|
2053
|
+
| "no-referrer"
|
2054
|
+
| "no-referrer-when-downgrade"
|
2055
|
+
| "origin"
|
2056
|
+
| "origin-when-cross-origin"
|
2057
|
+
| "same-origin"
|
2058
|
+
| "strict-origin"
|
2059
|
+
| "strict-origin-when-cross-origin"
|
2060
|
+
| "unsafe-url";
|
2006
2061
|
|
2007
2062
|
type HTMLAttributeAnchorTarget =
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2063
|
+
| "_self"
|
2064
|
+
| "_blank"
|
2065
|
+
| "_parent"
|
2066
|
+
| "_top"
|
2012
2067
|
| (string & {});
|
2013
2068
|
|
2014
2069
|
interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -2054,7 +2109,7 @@ declare namespace React {
|
|
2054
2109
|
formNoValidate?: boolean | undefined;
|
2055
2110
|
formTarget?: string | undefined;
|
2056
2111
|
name?: string | undefined;
|
2057
|
-
type?:
|
2112
|
+
type?: "submit" | "reset" | "button" | undefined;
|
2058
2113
|
value?: string | ReadonlyArray<string> | number | undefined;
|
2059
2114
|
}
|
2060
2115
|
|
@@ -2087,8 +2142,8 @@ declare namespace React {
|
|
2087
2142
|
}
|
2088
2143
|
|
2089
2144
|
interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
|
2090
|
-
onCancel?: ReactEventHandler<T> |
|
2091
|
-
onClose?: ReactEventHandler<T> |
|
2145
|
+
onCancel?: ReactEventHandler<T> | undefined;
|
2146
|
+
onClose?: ReactEventHandler<T> | undefined;
|
2092
2147
|
open?: boolean | undefined;
|
2093
2148
|
}
|
2094
2149
|
|
@@ -2163,38 +2218,38 @@ declare namespace React {
|
|
2163
2218
|
}
|
2164
2219
|
|
2165
2220
|
type HTMLInputTypeAttribute =
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2221
|
+
| "button"
|
2222
|
+
| "checkbox"
|
2223
|
+
| "color"
|
2224
|
+
| "date"
|
2225
|
+
| "datetime-local"
|
2226
|
+
| "email"
|
2227
|
+
| "file"
|
2228
|
+
| "hidden"
|
2229
|
+
| "image"
|
2230
|
+
| "month"
|
2231
|
+
| "number"
|
2232
|
+
| "password"
|
2233
|
+
| "radio"
|
2234
|
+
| "range"
|
2235
|
+
| "reset"
|
2236
|
+
| "search"
|
2237
|
+
| "submit"
|
2238
|
+
| "tel"
|
2239
|
+
| "text"
|
2240
|
+
| "time"
|
2241
|
+
| "url"
|
2242
|
+
| "week"
|
2188
2243
|
| (string & {});
|
2189
2244
|
|
2190
2245
|
interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
|
2191
2246
|
accept?: string | undefined;
|
2192
2247
|
alt?: string | undefined;
|
2193
2248
|
autoComplete?: string | undefined;
|
2194
|
-
capture?: boolean |
|
2249
|
+
capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
|
2195
2250
|
checked?: boolean | undefined;
|
2196
2251
|
disabled?: boolean | undefined;
|
2197
|
-
enterKeyHint?:
|
2252
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
2198
2253
|
form?: string | undefined;
|
2199
2254
|
formAction?: string | undefined;
|
2200
2255
|
formEncType?: string | undefined;
|
@@ -2313,7 +2368,7 @@ declare namespace React {
|
|
2313
2368
|
interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
|
2314
2369
|
reversed?: boolean | undefined;
|
2315
2370
|
start?: number | undefined;
|
2316
|
-
type?:
|
2371
|
+
type?: "1" | "a" | "A" | "i" | "I" | undefined;
|
2317
2372
|
}
|
2318
2373
|
|
2319
2374
|
interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -2492,8 +2547,21 @@ declare namespace React {
|
|
2492
2547
|
accentHeight?: number | string | undefined;
|
2493
2548
|
accumulate?: "none" | "sum" | undefined;
|
2494
2549
|
additive?: "replace" | "sum" | undefined;
|
2495
|
-
alignmentBaseline?:
|
2496
|
-
|
2550
|
+
alignmentBaseline?:
|
2551
|
+
| "auto"
|
2552
|
+
| "baseline"
|
2553
|
+
| "before-edge"
|
2554
|
+
| "text-before-edge"
|
2555
|
+
| "middle"
|
2556
|
+
| "central"
|
2557
|
+
| "after-edge"
|
2558
|
+
| "text-after-edge"
|
2559
|
+
| "ideographic"
|
2560
|
+
| "alphabetic"
|
2561
|
+
| "hanging"
|
2562
|
+
| "mathematical"
|
2563
|
+
| "inherit"
|
2564
|
+
| undefined;
|
2497
2565
|
allowReorder?: "no" | "yes" | undefined;
|
2498
2566
|
alphabetic?: number | string | undefined;
|
2499
2567
|
amplitude?: number | string | undefined;
|
@@ -2934,7 +3002,7 @@ declare namespace React {
|
|
2934
3002
|
view: SVGFactory;
|
2935
3003
|
}
|
2936
3004
|
|
2937
|
-
interface ReactDOM extends ReactHTML, ReactSVG {
|
3005
|
+
interface ReactDOM extends ReactHTML, ReactSVG {}
|
2938
3006
|
|
2939
3007
|
//
|
2940
3008
|
// React.PropTypes
|
@@ -2947,11 +3015,9 @@ declare namespace React {
|
|
2947
3015
|
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
2948
3016
|
|
2949
3017
|
type WeakValidationMap<T> = {
|
2950
|
-
[K in keyof T]?: null extends T[K]
|
2951
|
-
? Validator<T[K] | null | undefined>
|
2952
|
-
:
|
2953
|
-
? Validator<T[K] | null | undefined>
|
2954
|
-
: Validator<T[K]>
|
3018
|
+
[K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
|
3019
|
+
: undefined extends T[K] ? Validator<T[K] | null | undefined>
|
3020
|
+
: Validator<T[K]>;
|
2955
3021
|
};
|
2956
3022
|
|
2957
3023
|
interface ReactPropTypes {
|
@@ -2978,8 +3044,10 @@ declare namespace React {
|
|
2978
3044
|
// ----------------------------------------------------------------------
|
2979
3045
|
|
2980
3046
|
interface ReactChildren {
|
2981
|
-
map<T, C>(
|
2982
|
-
C
|
3047
|
+
map<T, C>(
|
3048
|
+
children: C | ReadonlyArray<C>,
|
3049
|
+
fn: (child: C, index: number) => T,
|
3050
|
+
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
2983
3051
|
forEach<C>(children: C | ReadonlyArray<C>, fn: (child: C, index: number) => void): void;
|
2984
3052
|
count(children: any): number;
|
2985
3053
|
only<C>(children: C): C extends any[] ? never : C;
|
@@ -3050,58 +3118,62 @@ type MergePropTypes<P, T> =
|
|
3050
3118
|
// Distribute over P in case it is a union type
|
3051
3119
|
P extends any
|
3052
3120
|
// If props is type any, use propTypes definitions
|
3053
|
-
? IsExactlyAny<P> extends true ? T
|
3121
|
+
? IsExactlyAny<P> extends true ? T
|
3054
3122
|
// If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3123
|
+
: string extends keyof P ? P
|
3124
|
+
// Prefer declared types which are not exactly any
|
3125
|
+
:
|
3126
|
+
& Pick<P, NotExactlyAnyPropertyKeys<P>>
|
3127
|
+
// For props which are exactly any, use the type inferred from propTypes if present
|
3128
|
+
& Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
|
3129
|
+
// Keep leftover props not specified in propTypes
|
3130
|
+
& Pick<P, Exclude<keyof P, keyof T>>
|
3062
3131
|
: never;
|
3063
3132
|
|
3064
3133
|
// Any prop that has a default prop becomes optional, but its type is unchanged
|
3065
3134
|
// Undeclared default props are augmented into the resulting allowable attributes
|
3066
3135
|
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
3067
3136
|
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
3068
|
-
type Defaultize<P, D> = P extends any
|
3069
|
-
|
3137
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
3138
|
+
:
|
3070
3139
|
& Pick<P, Exclude<keyof P, keyof D>>
|
3071
3140
|
& Partial<Pick<P, Extract<keyof P, keyof D>>>
|
3072
3141
|
& Partial<Pick<D, Exclude<keyof D, keyof P>>>
|
3073
3142
|
: never;
|
3074
3143
|
|
3075
|
-
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D
|
3144
|
+
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D }
|
3076
3145
|
? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
|
3077
|
-
: C extends { propTypes: infer T
|
3078
|
-
|
3079
|
-
|
3080
|
-
? Defaultize<P, D>
|
3081
|
-
: P;
|
3146
|
+
: C extends { propTypes: infer T } ? MergePropTypes<P, PropTypes.InferProps<T>>
|
3147
|
+
: C extends { defaultProps: infer D } ? Defaultize<P, D>
|
3148
|
+
: P;
|
3082
3149
|
|
3083
3150
|
declare global {
|
3084
3151
|
/**
|
3085
3152
|
* @deprecated Use `React.JSX` instead of the global `JSX` namespace.
|
3086
3153
|
*/
|
3087
3154
|
namespace JSX {
|
3088
|
-
interface Element extends React.ReactElement<any, any> {
|
3155
|
+
interface Element extends React.ReactElement<any, any> {}
|
3089
3156
|
interface ElementClass extends React.Component<any> {
|
3090
3157
|
render(): React.ReactNode;
|
3091
3158
|
}
|
3092
|
-
interface ElementAttributesProperty {
|
3093
|
-
|
3159
|
+
interface ElementAttributesProperty {
|
3160
|
+
props: {};
|
3161
|
+
}
|
3162
|
+
interface ElementChildrenAttribute {
|
3163
|
+
children: {};
|
3164
|
+
}
|
3094
3165
|
|
3095
3166
|
// We can't recurse forever because `type` can't be self-referential;
|
3096
3167
|
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
|
3097
|
-
type LibraryManagedAttributes<C, P> = C extends
|
3168
|
+
type LibraryManagedAttributes<C, P> = C extends
|
3169
|
+
React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
|
3098
3170
|
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
|
3099
3171
|
? ReactManagedAttributes<U, P>
|
3100
|
-
|
3172
|
+
: ReactManagedAttributes<T, P>
|
3101
3173
|
: ReactManagedAttributes<C, P>;
|
3102
3174
|
|
3103
|
-
interface IntrinsicAttributes extends React.Attributes {
|
3104
|
-
interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {
|
3175
|
+
interface IntrinsicAttributes extends React.Attributes {}
|
3176
|
+
interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {}
|
3105
3177
|
|
3106
3178
|
interface IntrinsicElements {
|
3107
3179
|
// HTML
|