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