@types/react 16.14.46 → 16.14.48
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 -295
- 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,8 +51,8 @@ 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.
|
@@ -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,16 +138,19 @@ 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
|
-
key:
|
147
|
+
key: string | null;
|
147
148
|
}
|
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;
|
@@ -186,7 +189,6 @@ declare namespace React {
|
|
186
189
|
}
|
187
190
|
|
188
191
|
interface ReactPortal extends ReactElement {
|
189
|
-
key: Key | null;
|
190
192
|
children: ReactNode;
|
191
193
|
}
|
192
194
|
|
@@ -201,16 +203,23 @@ declare namespace React {
|
|
201
203
|
*/
|
202
204
|
type SFCFactory<P> = FunctionComponentFactory<P>;
|
203
205
|
|
204
|
-
type FunctionComponentFactory<P> = (
|
206
|
+
type FunctionComponentFactory<P> = (
|
207
|
+
props?: Attributes & P,
|
208
|
+
...children: ReactNode[]
|
209
|
+
) => FunctionComponentElement<P>;
|
205
210
|
|
206
|
-
type ComponentFactory<P, T extends Component<P, ComponentState>> =
|
207
|
-
|
211
|
+
type ComponentFactory<P, T extends Component<P, ComponentState>> = (
|
212
|
+
props?: ClassAttributes<T> & P,
|
213
|
+
...children: ReactNode[]
|
214
|
+
) => CElement<P, T>;
|
208
215
|
|
209
216
|
type CFactory<P, T extends Component<P, ComponentState>> = ComponentFactory<P, T>;
|
210
217
|
type ClassicFactory<P> = CFactory<P, ClassicComponent<P, ComponentState>>;
|
211
218
|
|
212
|
-
type DOMFactory<P extends DOMAttributes<T>, T extends Element> =
|
213
|
-
|
219
|
+
type DOMFactory<P extends DOMAttributes<T>, T extends Element> = (
|
220
|
+
props?: ClassAttributes<T> & P | null,
|
221
|
+
...children: ReactNode[]
|
222
|
+
) => DOMElement<P, T>;
|
214
223
|
|
215
224
|
// tslint:disable-next-line:no-empty-interface
|
216
225
|
interface HTMLFactory<T extends HTMLElement> extends DetailedHTMLFactory<AllHTMLAttributes<T>, T> {}
|
@@ -220,7 +229,10 @@ declare namespace React {
|
|
220
229
|
}
|
221
230
|
|
222
231
|
interface SVGFactory extends DOMFactory<SVGAttributes<SVGElement>, SVGElement> {
|
223
|
-
(
|
232
|
+
(
|
233
|
+
props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null,
|
234
|
+
...children: ReactNode[]
|
235
|
+
): ReactSVGElement;
|
224
236
|
}
|
225
237
|
|
226
238
|
//
|
@@ -240,18 +252,23 @@ declare namespace React {
|
|
240
252
|
|
241
253
|
// DOM Elements
|
242
254
|
function createFactory<T extends HTMLElement>(
|
243
|
-
type: keyof ReactHTML
|
255
|
+
type: keyof ReactHTML,
|
256
|
+
): HTMLFactory<T>;
|
244
257
|
function createFactory(
|
245
|
-
type: keyof ReactSVG
|
258
|
+
type: keyof ReactSVG,
|
259
|
+
): SVGFactory;
|
246
260
|
function createFactory<P extends DOMAttributes<T>, T extends Element>(
|
247
|
-
type: string
|
261
|
+
type: string,
|
262
|
+
): DOMFactory<P, T>;
|
248
263
|
|
249
264
|
// Custom components
|
250
265
|
function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
|
251
266
|
function createFactory<P>(
|
252
|
-
type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P
|
267
|
+
type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P>>,
|
268
|
+
): CFactory<P, ClassicComponent<P, ComponentState>>;
|
253
269
|
function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
254
|
-
type: ClassType<P, T, C
|
270
|
+
type: ClassType<P, T, C>,
|
271
|
+
): CFactory<P, T>;
|
255
272
|
function createFactory<P>(type: ComponentClass<P>): Factory<P>;
|
256
273
|
|
257
274
|
// DOM Elements
|
@@ -259,74 +276,89 @@ declare namespace React {
|
|
259
276
|
function createElement(
|
260
277
|
type: "input",
|
261
278
|
props?: InputHTMLAttributes<HTMLInputElement> & ClassAttributes<HTMLInputElement> | null,
|
262
|
-
...children: ReactNode[]
|
279
|
+
...children: ReactNode[]
|
280
|
+
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
263
281
|
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
264
282
|
type: keyof ReactHTML,
|
265
283
|
props?: ClassAttributes<T> & P | null,
|
266
|
-
...children: ReactNode[]
|
284
|
+
...children: ReactNode[]
|
285
|
+
): DetailedReactHTMLElement<P, T>;
|
267
286
|
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
268
287
|
type: keyof ReactSVG,
|
269
288
|
props?: ClassAttributes<T> & P | null,
|
270
|
-
...children: ReactNode[]
|
289
|
+
...children: ReactNode[]
|
290
|
+
): ReactSVGElement;
|
271
291
|
function createElement<P extends DOMAttributes<T>, T extends Element>(
|
272
292
|
type: string,
|
273
293
|
props?: ClassAttributes<T> & P | null,
|
274
|
-
...children: ReactNode[]
|
294
|
+
...children: ReactNode[]
|
295
|
+
): DOMElement<P, T>;
|
275
296
|
|
276
297
|
// Custom components
|
277
298
|
|
278
299
|
function createElement<P extends {}>(
|
279
300
|
type: FunctionComponent<P>,
|
280
301
|
props?: Attributes & P | null,
|
281
|
-
...children: ReactNode[]
|
302
|
+
...children: ReactNode[]
|
303
|
+
): FunctionComponentElement<P>;
|
282
304
|
function createElement<P extends {}>(
|
283
305
|
type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P>>,
|
284
306
|
props?: ClassAttributes<ClassicComponent<P, ComponentState>> & P | null,
|
285
|
-
...children: ReactNode[]
|
307
|
+
...children: ReactNode[]
|
308
|
+
): CElement<P, ClassicComponent<P, ComponentState>>;
|
286
309
|
function createElement<P extends {}, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
287
310
|
type: ClassType<P, T, C>,
|
288
311
|
props?: ClassAttributes<T> & P | null,
|
289
|
-
...children: ReactNode[]
|
312
|
+
...children: ReactNode[]
|
313
|
+
): CElement<P, T>;
|
290
314
|
function createElement<P extends {}>(
|
291
315
|
type: FunctionComponent<P> | ComponentClass<P> | string,
|
292
316
|
props?: Attributes & P | null,
|
293
|
-
...children: ReactNode[]
|
317
|
+
...children: ReactNode[]
|
318
|
+
): ReactElement<P>;
|
294
319
|
|
295
320
|
// DOM Elements
|
296
321
|
// ReactHTMLElement
|
297
322
|
function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
298
323
|
element: DetailedReactHTMLElement<P, T>,
|
299
324
|
props?: P,
|
300
|
-
...children: ReactNode[]
|
325
|
+
...children: ReactNode[]
|
326
|
+
): DetailedReactHTMLElement<P, T>;
|
301
327
|
// ReactHTMLElement, less specific
|
302
328
|
function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
303
329
|
element: ReactHTMLElement<T>,
|
304
330
|
props?: P,
|
305
|
-
...children: ReactNode[]
|
331
|
+
...children: ReactNode[]
|
332
|
+
): ReactHTMLElement<T>;
|
306
333
|
// SVGElement
|
307
334
|
function cloneElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
308
335
|
element: ReactSVGElement,
|
309
336
|
props?: P,
|
310
|
-
...children: ReactNode[]
|
337
|
+
...children: ReactNode[]
|
338
|
+
): ReactSVGElement;
|
311
339
|
// DOM Element (has to be the last, because type checking stops at first overload that fits)
|
312
340
|
function cloneElement<P extends DOMAttributes<T>, T extends Element>(
|
313
341
|
element: DOMElement<P, T>,
|
314
342
|
props?: DOMAttributes<T> & P,
|
315
|
-
...children: ReactNode[]
|
343
|
+
...children: ReactNode[]
|
344
|
+
): DOMElement<P, T>;
|
316
345
|
|
317
346
|
// Custom components
|
318
347
|
function cloneElement<P>(
|
319
348
|
element: FunctionComponentElement<P>,
|
320
349
|
props?: Partial<P> & Attributes,
|
321
|
-
...children: ReactNode[]
|
350
|
+
...children: ReactNode[]
|
351
|
+
): FunctionComponentElement<P>;
|
322
352
|
function cloneElement<P, T extends Component<P, ComponentState>>(
|
323
353
|
element: CElement<P, T>,
|
324
354
|
props?: Partial<P> & ClassAttributes<T>,
|
325
|
-
...children: ReactNode[]
|
355
|
+
...children: ReactNode[]
|
356
|
+
): CElement<P, T>;
|
326
357
|
function cloneElement<P>(
|
327
358
|
element: ReactElement<P>,
|
328
359
|
props?: Partial<P> & Attributes,
|
329
|
-
...children: ReactNode[]
|
360
|
+
...children: ReactNode[]
|
361
|
+
): ReactElement<P>;
|
330
362
|
|
331
363
|
// Context via RenderProps
|
332
364
|
interface ProviderProps<T> {
|
@@ -352,7 +384,7 @@ declare namespace React {
|
|
352
384
|
/**
|
353
385
|
* **NOTE**: Exotic components are not callable.
|
354
386
|
*/
|
355
|
-
(props: P):
|
387
|
+
(props: P): ReactElement | null;
|
356
388
|
readonly $$typeof: symbol;
|
357
389
|
}
|
358
390
|
|
@@ -391,7 +423,7 @@ declare namespace React {
|
|
391
423
|
children?: ReactNode | undefined;
|
392
424
|
|
393
425
|
/** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
|
394
|
-
fallback: NonNullable<ReactNode
|
426
|
+
fallback: NonNullable<ReactNode> | null;
|
395
427
|
}
|
396
428
|
/**
|
397
429
|
* This feature is not yet available for server-side rendering.
|
@@ -428,7 +460,7 @@ declare namespace React {
|
|
428
460
|
|
429
461
|
// Base component for plain JS classes
|
430
462
|
// tslint:disable-next-line:no-empty-interface
|
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,24 +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
|
// Just Pick would be sufficient for this, but I'm trying to avoid unnecessary mapping over union types
|
808
842
|
// https://github.com/Microsoft/TypeScript/issues/28339
|
809
|
-
|
810
|
-
? Pick<P, Exclude<keyof P, 'ref'>>
|
843
|
+
"ref" extends keyof P ? Pick<P, Exclude<keyof P, "ref">>
|
811
844
|
: P;
|
812
845
|
/** Ensures that the props do not include string ref, which cannot be forwarded */
|
813
846
|
type PropsWithRef<P> =
|
814
847
|
// Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
|
815
|
-
|
848
|
+
"ref" extends keyof P
|
816
849
|
? P extends { ref?: infer R | undefined }
|
817
|
-
? string extends R
|
818
|
-
? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
819
|
-
: P
|
850
|
+
? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
|
820
851
|
: P
|
852
|
+
: P
|
821
853
|
: P;
|
822
854
|
|
823
855
|
type PropsWithChildren<P> = P & { children?: ReactNode | undefined };
|
@@ -826,26 +858,20 @@ declare namespace React {
|
|
826
858
|
* NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,
|
827
859
|
* or ComponentPropsWithoutRef when refs are not supported.
|
828
860
|
*/
|
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>>;
|
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>>;
|
841
869
|
|
842
870
|
type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
|
843
871
|
ComponentPropsWithoutRef<T> & RefAttributes<infer Method>
|
844
|
-
>
|
845
|
-
? Method
|
846
|
-
:
|
847
|
-
? Method
|
848
|
-
: never;
|
872
|
+
> ? Method
|
873
|
+
: ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
874
|
+
: never;
|
849
875
|
|
850
876
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
851
877
|
// but can be given its own specific name
|
@@ -855,11 +881,14 @@ declare namespace React {
|
|
855
881
|
|
856
882
|
function memo<P extends object>(
|
857
883
|
Component: SFC<P>,
|
858
|
-
propsAreEqual?: (
|
884
|
+
propsAreEqual?: (
|
885
|
+
prevProps: Readonly<PropsWithChildren<P>>,
|
886
|
+
nextProps: Readonly<PropsWithChildren<P>>,
|
887
|
+
) => boolean,
|
859
888
|
): NamedExoticComponent<P>;
|
860
889
|
function memo<T extends ComponentType<any>>(
|
861
890
|
Component: T,
|
862
|
-
propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean
|
891
|
+
propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
|
863
892
|
): MemoExoticComponent<T>;
|
864
893
|
|
865
894
|
type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
|
@@ -867,7 +896,7 @@ declare namespace React {
|
|
867
896
|
};
|
868
897
|
|
869
898
|
function lazy<T extends ComponentType<any>>(
|
870
|
-
factory: () => Promise<{ default: T }
|
899
|
+
factory: () => Promise<{ default: T }>,
|
871
900
|
): LazyExoticComponent<T>;
|
872
901
|
|
873
902
|
//
|
@@ -892,13 +921,13 @@ declare namespace React {
|
|
892
921
|
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
893
922
|
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
|
894
923
|
// The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
|
895
|
-
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> =
|
896
|
-
|
924
|
+
type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
|
925
|
+
: never;
|
897
926
|
// TODO (TypeScript 3.0): ReadonlyArray<unknown>
|
898
927
|
type DependencyList = ReadonlyArray<any>;
|
899
928
|
|
900
929
|
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
901
|
-
type EffectCallback = () =>
|
930
|
+
type EffectCallback = () => void | Destructor;
|
902
931
|
|
903
932
|
interface MutableRefObject<T> {
|
904
933
|
current: T;
|
@@ -912,7 +941,7 @@ declare namespace React {
|
|
912
941
|
* @version 16.8.0
|
913
942
|
* @see https://react.dev/reference/react/useContext
|
914
943
|
*/
|
915
|
-
function useContext<T>(context: Context<T
|
944
|
+
function useContext<T>(context: Context<T> /*, (not public API) observedBits?: number|boolean */): T;
|
916
945
|
/**
|
917
946
|
* Returns a stateful value, and a function to update it.
|
918
947
|
*
|
@@ -942,7 +971,7 @@ declare namespace React {
|
|
942
971
|
function useReducer<R extends ReducerWithoutAction<any>, I>(
|
943
972
|
reducer: R,
|
944
973
|
initializerArg: I,
|
945
|
-
initializer: (arg: I) => ReducerStateWithoutAction<R
|
974
|
+
initializer: (arg: I) => ReducerStateWithoutAction<R>,
|
946
975
|
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
947
976
|
/**
|
948
977
|
* An alternative to `useState`.
|
@@ -958,7 +987,7 @@ declare namespace React {
|
|
958
987
|
function useReducer<R extends ReducerWithoutAction<any>>(
|
959
988
|
reducer: R,
|
960
989
|
initializerArg: ReducerStateWithoutAction<R>,
|
961
|
-
initializer?: undefined
|
990
|
+
initializer?: undefined,
|
962
991
|
): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
|
963
992
|
/**
|
964
993
|
* An alternative to `useState`.
|
@@ -976,7 +1005,7 @@ declare namespace React {
|
|
976
1005
|
function useReducer<R extends Reducer<any, any>, I>(
|
977
1006
|
reducer: R,
|
978
1007
|
initializerArg: I & ReducerState<R>,
|
979
|
-
initializer: (arg: I & ReducerState<R>) => ReducerState<R
|
1008
|
+
initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
|
980
1009
|
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
981
1010
|
/**
|
982
1011
|
* An alternative to `useState`.
|
@@ -992,7 +1021,7 @@ declare namespace React {
|
|
992
1021
|
function useReducer<R extends Reducer<any, any>, I>(
|
993
1022
|
reducer: R,
|
994
1023
|
initializerArg: I,
|
995
|
-
initializer: (arg: I) => ReducerState<R
|
1024
|
+
initializer: (arg: I) => ReducerState<R>,
|
996
1025
|
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
997
1026
|
/**
|
998
1027
|
* An alternative to `useState`.
|
@@ -1017,7 +1046,7 @@ declare namespace React {
|
|
1017
1046
|
function useReducer<R extends Reducer<any, any>>(
|
1018
1047
|
reducer: R,
|
1019
1048
|
initialState: ReducerState<R>,
|
1020
|
-
initializer?: undefined
|
1049
|
+
initializer?: undefined,
|
1021
1050
|
): [ReducerState<R>, Dispatch<ReducerAction<R>>];
|
1022
1051
|
/**
|
1023
1052
|
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
@@ -1044,7 +1073,7 @@ declare namespace React {
|
|
1044
1073
|
* @version 16.8.0
|
1045
1074
|
* @see https://react.dev/reference/react/useRef
|
1046
1075
|
*/
|
1047
|
-
function useRef<T>(initialValue: T|null): RefObject<T>;
|
1076
|
+
function useRef<T>(initialValue: T | null): RefObject<T>;
|
1048
1077
|
// convenience overload for potentially undefined initialValue / call with 0 arguments
|
1049
1078
|
// has a default to stop it from defaulting to {} instead
|
1050
1079
|
/**
|
@@ -1092,7 +1121,7 @@ declare namespace React {
|
|
1092
1121
|
* @version 16.8.0
|
1093
1122
|
* @see https://react.dev/reference/react/useImperativeHandle
|
1094
1123
|
*/
|
1095
|
-
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;
|
1096
1125
|
// I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key
|
1097
1126
|
// useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y.
|
1098
1127
|
/**
|
@@ -1177,7 +1206,7 @@ declare namespace React {
|
|
1177
1206
|
twist: number;
|
1178
1207
|
width: number;
|
1179
1208
|
height: number;
|
1180
|
-
pointerType:
|
1209
|
+
pointerType: "mouse" | "pen" | "touch";
|
1181
1210
|
isPrimary: boolean;
|
1182
1211
|
}
|
1183
1212
|
|
@@ -1198,7 +1227,21 @@ declare namespace React {
|
|
1198
1227
|
target: EventTarget & T;
|
1199
1228
|
}
|
1200
1229
|
|
1201
|
-
export type ModifierKey =
|
1230
|
+
export type ModifierKey =
|
1231
|
+
| "Alt"
|
1232
|
+
| "AltGraph"
|
1233
|
+
| "CapsLock"
|
1234
|
+
| "Control"
|
1235
|
+
| "Fn"
|
1236
|
+
| "FnLock"
|
1237
|
+
| "Hyper"
|
1238
|
+
| "Meta"
|
1239
|
+
| "NumLock"
|
1240
|
+
| "ScrollLock"
|
1241
|
+
| "Shift"
|
1242
|
+
| "Super"
|
1243
|
+
| "Symbol"
|
1244
|
+
| "SymbolLock";
|
1202
1245
|
|
1203
1246
|
interface KeyboardEvent<T = Element> extends UIEvent<T, NativeKeyboardEvent> {
|
1204
1247
|
altKey: boolean;
|
@@ -1557,262 +1600,273 @@ declare namespace React {
|
|
1557
1600
|
// All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
|
1558
1601
|
interface AriaAttributes {
|
1559
1602
|
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
|
1560
|
-
|
1603
|
+
"aria-activedescendant"?: string | undefined;
|
1561
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. */
|
1562
|
-
|
1605
|
+
"aria-atomic"?: boolean | "false" | "true" | undefined;
|
1563
1606
|
/**
|
1564
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
|
1565
1608
|
* presented if they are made.
|
1566
1609
|
*/
|
1567
|
-
|
1610
|
+
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
|
1568
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. */
|
1569
|
-
|
1612
|
+
"aria-busy"?: boolean | "false" | "true" | undefined;
|
1570
1613
|
/**
|
1571
1614
|
* Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
|
1572
1615
|
* @see aria-pressed @see aria-selected.
|
1573
1616
|
*/
|
1574
|
-
|
1617
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
1575
1618
|
/**
|
1576
1619
|
* Defines the total number of columns in a table, grid, or treegrid.
|
1577
1620
|
* @see aria-colindex.
|
1578
1621
|
*/
|
1579
|
-
|
1622
|
+
"aria-colcount"?: number | undefined;
|
1580
1623
|
/**
|
1581
1624
|
* Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
|
1582
1625
|
* @see aria-colcount @see aria-colspan.
|
1583
1626
|
*/
|
1584
|
-
|
1627
|
+
"aria-colindex"?: number | undefined;
|
1585
1628
|
/**
|
1586
1629
|
* Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
|
1587
1630
|
* @see aria-colindex @see aria-rowspan.
|
1588
1631
|
*/
|
1589
|
-
|
1632
|
+
"aria-colspan"?: number | undefined;
|
1590
1633
|
/**
|
1591
1634
|
* Identifies the element (or elements) whose contents or presence are controlled by the current element.
|
1592
1635
|
* @see aria-owns.
|
1593
1636
|
*/
|
1594
|
-
|
1637
|
+
"aria-controls"?: string | undefined;
|
1595
1638
|
/** Indicates the element that represents the current item within a container or set of related elements. */
|
1596
|
-
|
1639
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
1597
1640
|
/**
|
1598
1641
|
* Identifies the element (or elements) that describes the object.
|
1599
1642
|
* @see aria-labelledby
|
1600
1643
|
*/
|
1601
|
-
|
1644
|
+
"aria-describedby"?: string | undefined;
|
1602
1645
|
/**
|
1603
1646
|
* Identifies the element that provides a detailed, extended description for the object.
|
1604
1647
|
* @see aria-describedby.
|
1605
1648
|
*/
|
1606
|
-
|
1649
|
+
"aria-details"?: string | undefined;
|
1607
1650
|
/**
|
1608
1651
|
* Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
|
1609
1652
|
* @see aria-hidden @see aria-readonly.
|
1610
1653
|
*/
|
1611
|
-
|
1654
|
+
"aria-disabled"?: boolean | "false" | "true" | undefined;
|
1612
1655
|
/**
|
1613
1656
|
* Indicates what functions can be performed when a dragged object is released on the drop target.
|
1614
1657
|
* @deprecated in ARIA 1.1
|
1615
1658
|
*/
|
1616
|
-
|
1659
|
+
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
|
1617
1660
|
/**
|
1618
1661
|
* Identifies the element that provides an error message for the object.
|
1619
1662
|
* @see aria-invalid @see aria-describedby.
|
1620
1663
|
*/
|
1621
|
-
|
1664
|
+
"aria-errormessage"?: string | undefined;
|
1622
1665
|
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
|
1623
|
-
|
1666
|
+
"aria-expanded"?: boolean | "false" | "true" | undefined;
|
1624
1667
|
/**
|
1625
1668
|
* Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
|
1626
1669
|
* allows assistive technology to override the general default of reading in document source order.
|
1627
1670
|
*/
|
1628
|
-
|
1671
|
+
"aria-flowto"?: string | undefined;
|
1629
1672
|
/**
|
1630
1673
|
* Indicates an element's "grabbed" state in a drag-and-drop operation.
|
1631
1674
|
* @deprecated in ARIA 1.1
|
1632
1675
|
*/
|
1633
|
-
|
1676
|
+
"aria-grabbed"?: boolean | "false" | "true" | undefined;
|
1634
1677
|
/** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
|
1635
|
-
|
1678
|
+
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
|
1636
1679
|
/**
|
1637
1680
|
* Indicates whether the element is exposed to an accessibility API.
|
1638
1681
|
* @see aria-disabled.
|
1639
1682
|
*/
|
1640
|
-
|
1683
|
+
"aria-hidden"?: boolean | "false" | "true" | undefined;
|
1641
1684
|
/**
|
1642
1685
|
* Indicates the entered value does not conform to the format expected by the application.
|
1643
1686
|
* @see aria-errormessage.
|
1644
1687
|
*/
|
1645
|
-
|
1688
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
1646
1689
|
/** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
|
1647
|
-
|
1690
|
+
"aria-keyshortcuts"?: string | undefined;
|
1648
1691
|
/**
|
1649
1692
|
* Defines a string value that labels the current element.
|
1650
1693
|
* @see aria-labelledby.
|
1651
1694
|
*/
|
1652
|
-
|
1695
|
+
"aria-label"?: string | undefined;
|
1653
1696
|
/**
|
1654
1697
|
* Identifies the element (or elements) that labels the current element.
|
1655
1698
|
* @see aria-describedby.
|
1656
1699
|
*/
|
1657
|
-
|
1700
|
+
"aria-labelledby"?: string | undefined;
|
1658
1701
|
/** Defines the hierarchical level of an element within a structure. */
|
1659
|
-
|
1702
|
+
"aria-level"?: number | undefined;
|
1660
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. */
|
1661
|
-
|
1704
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
1662
1705
|
/** Indicates whether an element is modal when displayed. */
|
1663
|
-
|
1706
|
+
"aria-modal"?: boolean | "false" | "true" | undefined;
|
1664
1707
|
/** Indicates whether a text box accepts multiple lines of input or only a single line. */
|
1665
|
-
|
1708
|
+
"aria-multiline"?: boolean | "false" | "true" | undefined;
|
1666
1709
|
/** Indicates that the user may select more than one item from the current selectable descendants. */
|
1667
|
-
|
1710
|
+
"aria-multiselectable"?: boolean | "false" | "true" | undefined;
|
1668
1711
|
/** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
|
1669
|
-
|
1712
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
1670
1713
|
/**
|
1671
1714
|
* Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
|
1672
1715
|
* between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
|
1673
1716
|
* @see aria-controls.
|
1674
1717
|
*/
|
1675
|
-
|
1718
|
+
"aria-owns"?: string | undefined;
|
1676
1719
|
/**
|
1677
1720
|
* Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
|
1678
1721
|
* A hint could be a sample value or a brief description of the expected format.
|
1679
1722
|
*/
|
1680
|
-
|
1723
|
+
"aria-placeholder"?: string | undefined;
|
1681
1724
|
/**
|
1682
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.
|
1683
1726
|
* @see aria-setsize.
|
1684
1727
|
*/
|
1685
|
-
|
1728
|
+
"aria-posinset"?: number | undefined;
|
1686
1729
|
/**
|
1687
1730
|
* Indicates the current "pressed" state of toggle buttons.
|
1688
1731
|
* @see aria-checked @see aria-selected.
|
1689
1732
|
*/
|
1690
|
-
|
1733
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
1691
1734
|
/**
|
1692
1735
|
* Indicates that the element is not editable, but is otherwise operable.
|
1693
1736
|
* @see aria-disabled.
|
1694
1737
|
*/
|
1695
|
-
|
1738
|
+
"aria-readonly"?: boolean | "false" | "true" | undefined;
|
1696
1739
|
/**
|
1697
1740
|
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
|
1698
1741
|
* @see aria-atomic.
|
1699
1742
|
*/
|
1700
|
-
|
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;
|
1701
1755
|
/** Indicates that user input is required on the element before a form may be submitted. */
|
1702
|
-
|
1756
|
+
"aria-required"?: boolean | "false" | "true" | undefined;
|
1703
1757
|
/** Defines a human-readable, author-localized description for the role of an element. */
|
1704
|
-
|
1758
|
+
"aria-roledescription"?: string | undefined;
|
1705
1759
|
/**
|
1706
1760
|
* Defines the total number of rows in a table, grid, or treegrid.
|
1707
1761
|
* @see aria-rowindex.
|
1708
1762
|
*/
|
1709
|
-
|
1763
|
+
"aria-rowcount"?: number | undefined;
|
1710
1764
|
/**
|
1711
1765
|
* Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
|
1712
1766
|
* @see aria-rowcount @see aria-rowspan.
|
1713
1767
|
*/
|
1714
|
-
|
1768
|
+
"aria-rowindex"?: number | undefined;
|
1715
1769
|
/**
|
1716
1770
|
* Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
|
1717
1771
|
* @see aria-rowindex @see aria-colspan.
|
1718
1772
|
*/
|
1719
|
-
|
1773
|
+
"aria-rowspan"?: number | undefined;
|
1720
1774
|
/**
|
1721
1775
|
* Indicates the current "selected" state of various widgets.
|
1722
1776
|
* @see aria-checked @see aria-pressed.
|
1723
1777
|
*/
|
1724
|
-
|
1778
|
+
"aria-selected"?: boolean | "false" | "true" | undefined;
|
1725
1779
|
/**
|
1726
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.
|
1727
1781
|
* @see aria-posinset.
|
1728
1782
|
*/
|
1729
|
-
|
1783
|
+
"aria-setsize"?: number | undefined;
|
1730
1784
|
/** Indicates if items in a table or grid are sorted in ascending or descending order. */
|
1731
|
-
|
1785
|
+
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
1732
1786
|
/** Defines the maximum allowed value for a range widget. */
|
1733
|
-
|
1787
|
+
"aria-valuemax"?: number | undefined;
|
1734
1788
|
/** Defines the minimum allowed value for a range widget. */
|
1735
|
-
|
1789
|
+
"aria-valuemin"?: number | undefined;
|
1736
1790
|
/**
|
1737
1791
|
* Defines the current value for a range widget.
|
1738
1792
|
* @see aria-valuetext.
|
1739
1793
|
*/
|
1740
|
-
|
1794
|
+
"aria-valuenow"?: number | undefined;
|
1741
1795
|
/** Defines the human readable text alternative of aria-valuenow for a range widget. */
|
1742
|
-
|
1796
|
+
"aria-valuetext"?: string | undefined;
|
1743
1797
|
}
|
1744
1798
|
|
1745
1799
|
// All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
|
1746
1800
|
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
|
-
|
|
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"
|
1816
1870
|
| (string & {});
|
1817
1871
|
|
1818
1872
|
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
@@ -1840,7 +1894,7 @@ declare namespace React {
|
|
1840
1894
|
style?: CSSProperties | undefined;
|
1841
1895
|
tabIndex?: number | undefined;
|
1842
1896
|
title?: string | undefined;
|
1843
|
-
translate?:
|
1897
|
+
translate?: "yes" | "no" | undefined;
|
1844
1898
|
|
1845
1899
|
// Unknown
|
1846
1900
|
radioGroup?: string | undefined; // <command>, <menuitem>
|
@@ -1873,14 +1927,14 @@ declare namespace React {
|
|
1873
1927
|
itemRef?: string | undefined;
|
1874
1928
|
results?: number | undefined;
|
1875
1929
|
security?: string | undefined;
|
1876
|
-
unselectable?:
|
1930
|
+
unselectable?: "on" | "off" | undefined;
|
1877
1931
|
|
1878
1932
|
// Living Standard
|
1879
1933
|
/**
|
1880
1934
|
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
1881
1935
|
* @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
|
1882
1936
|
*/
|
1883
|
-
inputMode?:
|
1937
|
+
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
|
1884
1938
|
/**
|
1885
1939
|
* Specify that a standard HTML element should behave like a defined custom built-in element
|
1886
1940
|
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
|
@@ -1995,21 +2049,21 @@ declare namespace React {
|
|
1995
2049
|
}
|
1996
2050
|
|
1997
2051
|
type HTMLAttributeReferrerPolicy =
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
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";
|
2007
2061
|
|
2008
2062
|
type HTMLAttributeAnchorTarget =
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2063
|
+
| "_self"
|
2064
|
+
| "_blank"
|
2065
|
+
| "_parent"
|
2066
|
+
| "_top"
|
2013
2067
|
| (string & {});
|
2014
2068
|
|
2015
2069
|
interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -2056,7 +2110,7 @@ declare namespace React {
|
|
2056
2110
|
formNoValidate?: boolean | undefined;
|
2057
2111
|
formTarget?: string | undefined;
|
2058
2112
|
name?: string | undefined;
|
2059
|
-
type?:
|
2113
|
+
type?: "submit" | "reset" | "button" | undefined;
|
2060
2114
|
value?: string | ReadonlyArray<string> | number | undefined;
|
2061
2115
|
}
|
2062
2116
|
|
@@ -2089,8 +2143,8 @@ declare namespace React {
|
|
2089
2143
|
}
|
2090
2144
|
|
2091
2145
|
interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
|
2092
|
-
onCancel?: ReactEventHandler<T> |
|
2093
|
-
onClose?: ReactEventHandler<T> |
|
2146
|
+
onCancel?: ReactEventHandler<T> | undefined;
|
2147
|
+
onClose?: ReactEventHandler<T> | undefined;
|
2094
2148
|
open?: boolean | undefined;
|
2095
2149
|
}
|
2096
2150
|
|
@@ -2165,28 +2219,28 @@ declare namespace React {
|
|
2165
2219
|
}
|
2166
2220
|
|
2167
2221
|
type HTMLInputTypeAttribute =
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2222
|
+
| "button"
|
2223
|
+
| "checkbox"
|
2224
|
+
| "color"
|
2225
|
+
| "date"
|
2226
|
+
| "datetime-local"
|
2227
|
+
| "email"
|
2228
|
+
| "file"
|
2229
|
+
| "hidden"
|
2230
|
+
| "image"
|
2231
|
+
| "month"
|
2232
|
+
| "number"
|
2233
|
+
| "password"
|
2234
|
+
| "radio"
|
2235
|
+
| "range"
|
2236
|
+
| "reset"
|
2237
|
+
| "search"
|
2238
|
+
| "submit"
|
2239
|
+
| "tel"
|
2240
|
+
| "text"
|
2241
|
+
| "time"
|
2242
|
+
| "url"
|
2243
|
+
| "week"
|
2190
2244
|
| (string & {});
|
2191
2245
|
|
2192
2246
|
interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -2314,7 +2368,7 @@ declare namespace React {
|
|
2314
2368
|
interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
|
2315
2369
|
reversed?: boolean | undefined;
|
2316
2370
|
start?: number | undefined;
|
2317
|
-
type?:
|
2371
|
+
type?: "1" | "a" | "A" | "i" | "I" | undefined;
|
2318
2372
|
}
|
2319
2373
|
|
2320
2374
|
interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
|
@@ -2492,8 +2546,21 @@ declare namespace React {
|
|
2492
2546
|
accentHeight?: number | string | undefined;
|
2493
2547
|
accumulate?: "none" | "sum" | undefined;
|
2494
2548
|
additive?: "replace" | "sum" | undefined;
|
2495
|
-
alignmentBaseline?:
|
2496
|
-
|
2549
|
+
alignmentBaseline?:
|
2550
|
+
| "auto"
|
2551
|
+
| "baseline"
|
2552
|
+
| "before-edge"
|
2553
|
+
| "text-before-edge"
|
2554
|
+
| "middle"
|
2555
|
+
| "central"
|
2556
|
+
| "after-edge"
|
2557
|
+
| "text-after-edge"
|
2558
|
+
| "ideographic"
|
2559
|
+
| "alphabetic"
|
2560
|
+
| "hanging"
|
2561
|
+
| "mathematical"
|
2562
|
+
| "inherit"
|
2563
|
+
| undefined;
|
2497
2564
|
allowReorder?: "no" | "yes" | undefined;
|
2498
2565
|
alphabetic?: number | string | undefined;
|
2499
2566
|
amplitude?: number | string | undefined;
|
@@ -2934,7 +3001,7 @@ declare namespace React {
|
|
2934
3001
|
view: SVGFactory;
|
2935
3002
|
}
|
2936
3003
|
|
2937
|
-
interface ReactDOM extends ReactHTML, ReactSVG {
|
3004
|
+
interface ReactDOM extends ReactHTML, ReactSVG {}
|
2938
3005
|
|
2939
3006
|
//
|
2940
3007
|
// React.PropTypes
|
@@ -2947,11 +3014,9 @@ declare namespace React {
|
|
2947
3014
|
type ValidationMap<T> = PropTypes.ValidationMap<T>;
|
2948
3015
|
|
2949
3016
|
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]>
|
3017
|
+
[K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
|
3018
|
+
: undefined extends T[K] ? Validator<T[K] | null | undefined>
|
3019
|
+
: Validator<T[K]>;
|
2955
3020
|
};
|
2956
3021
|
|
2957
3022
|
interface ReactPropTypes {
|
@@ -2978,8 +3043,10 @@ declare namespace React {
|
|
2978
3043
|
// ----------------------------------------------------------------------
|
2979
3044
|
|
2980
3045
|
interface ReactChildren {
|
2981
|
-
map<T, C>(
|
2982
|
-
C
|
3046
|
+
map<T, C>(
|
3047
|
+
children: C | C[],
|
3048
|
+
fn: (child: C, index: number) => T,
|
3049
|
+
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
2983
3050
|
forEach<C>(children: C | C[], fn: (child: C, index: number) => void): void;
|
2984
3051
|
count(children: any): number;
|
2985
3052
|
only<C>(children: C): C extends any[] ? never : C;
|
@@ -3050,15 +3117,16 @@ type MergePropTypes<P, T> =
|
|
3050
3117
|
// Distribute over P in case it is a union type
|
3051
3118
|
P extends any
|
3052
3119
|
// If props is type any, use propTypes definitions
|
3053
|
-
? IsExactlyAny<P> extends true ? T
|
3120
|
+
? IsExactlyAny<P> extends true ? T
|
3054
3121
|
// If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3122
|
+
: string extends keyof P ? P
|
3123
|
+
// Prefer declared types which are not exactly any
|
3124
|
+
:
|
3125
|
+
& Pick<P, NotExactlyAnyPropertyKeys<P>>
|
3126
|
+
// For props which are exactly any, use the type inferred from propTypes if present
|
3127
|
+
& Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
|
3128
|
+
// Keep leftover props not specified in propTypes
|
3129
|
+
& Pick<P, Exclude<keyof P, keyof T>>
|
3062
3130
|
: never;
|
3063
3131
|
|
3064
3132
|
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
@@ -3067,20 +3135,18 @@ type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
|
3067
3135
|
// Undeclared default props are augmented into the resulting allowable attributes
|
3068
3136
|
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
3069
3137
|
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
3070
|
-
type Defaultize<P, D> = P extends any
|
3071
|
-
|
3138
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
3139
|
+
:
|
3072
3140
|
& Pick<P, Exclude<keyof P, keyof D>>
|
3073
3141
|
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
3074
3142
|
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
3075
3143
|
: never;
|
3076
3144
|
|
3077
|
-
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D
|
3145
|
+
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D }
|
3078
3146
|
? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
|
3079
|
-
: C extends { propTypes: infer T
|
3080
|
-
|
3081
|
-
|
3082
|
-
? Defaultize<P, D>
|
3083
|
-
: P;
|
3147
|
+
: C extends { propTypes: infer T } ? MergePropTypes<P, PropTypes.InferProps<T>>
|
3148
|
+
: C extends { defaultProps: infer D } ? Defaultize<P, D>
|
3149
|
+
: P;
|
3084
3150
|
|
3085
3151
|
declare global {
|
3086
3152
|
/**
|
@@ -3088,25 +3154,30 @@ declare global {
|
|
3088
3154
|
*/
|
3089
3155
|
namespace JSX {
|
3090
3156
|
// tslint:disable-next-line:no-empty-interface
|
3091
|
-
interface Element extends React.ReactElement<any, any> {
|
3157
|
+
interface Element extends React.ReactElement<any, any> {}
|
3092
3158
|
interface ElementClass extends React.Component<any> {
|
3093
3159
|
render(): React.ReactNode;
|
3094
3160
|
}
|
3095
|
-
interface ElementAttributesProperty {
|
3096
|
-
|
3161
|
+
interface ElementAttributesProperty {
|
3162
|
+
props: {};
|
3163
|
+
}
|
3164
|
+
interface ElementChildrenAttribute {
|
3165
|
+
children: {};
|
3166
|
+
}
|
3097
3167
|
|
3098
3168
|
// We can't recurse forever because `type` can't be self-referential;
|
3099
3169
|
// 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
|
3170
|
+
type LibraryManagedAttributes<C, P> = C extends
|
3171
|
+
React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
|
3101
3172
|
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
|
3102
3173
|
? ReactManagedAttributes<U, P>
|
3103
|
-
|
3174
|
+
: ReactManagedAttributes<T, P>
|
3104
3175
|
: ReactManagedAttributes<C, P>;
|
3105
3176
|
|
3106
3177
|
// tslint:disable-next-line:no-empty-interface
|
3107
|
-
interface IntrinsicAttributes extends React.Attributes {
|
3178
|
+
interface IntrinsicAttributes extends React.Attributes {}
|
3108
3179
|
// tslint:disable-next-line:no-empty-interface
|
3109
|
-
interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {
|
3180
|
+
interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {}
|
3110
3181
|
|
3111
3182
|
interface IntrinsicElements {
|
3112
3183
|
// HTML
|