@types/react 18.3.13 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
react/ts5.0/index.d.ts CHANGED
@@ -5,7 +5,6 @@
5
5
  /// <reference path="global.d.ts" />
6
6
 
7
7
  import * as CSS from "csstype";
8
- import * as PropTypes from "prop-types";
9
8
 
10
9
  type NativeAnimationEvent = AnimationEvent;
11
10
  type NativeClipboardEvent = ClipboardEvent;
@@ -16,6 +15,7 @@ type NativeKeyboardEvent = KeyboardEvent;
16
15
  type NativeMouseEvent = MouseEvent;
17
16
  type NativeTouchEvent = TouchEvent;
18
17
  type NativePointerEvent = PointerEvent;
18
+ type NativeToggleEvent = ToggleEvent;
19
19
  type NativeTransitionEvent = TransitionEvent;
20
20
  type NativeUIEvent = UIEvent;
21
21
  type NativeWheelEvent = WheelEvent;
@@ -33,6 +33,25 @@ type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
33
33
 
34
34
  declare const UNDEFINED_VOID_ONLY: unique symbol;
35
35
 
36
+ /**
37
+ * @internal Use `Awaited<ReactNode>` instead
38
+ */
39
+ // Helper type to enable `Awaited<ReactNode>`.
40
+ // Must be a copy of the non-thenables of `ReactNode`.
41
+ type AwaitedReactNode =
42
+ | React.ReactElement
43
+ | string
44
+ | number
45
+ | bigint
46
+ | Iterable<React.ReactNode>
47
+ | React.ReactPortal
48
+ | boolean
49
+ | null
50
+ | undefined
51
+ | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
52
+ keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
53
+ ];
54
+
36
55
  /**
37
56
  * The function returned from an effect passed to {@link React.useEffect useEffect},
38
57
  * which can be used to clean up the effect when the component unmounts.
@@ -93,8 +112,7 @@ declare namespace React {
93
112
  * Represents any user-defined component, either as a function or a class.
94
113
  *
95
114
  * Similar to {@link JSXElementConstructor}, but with extra properties like
96
- * {@link FunctionComponent.defaultProps defaultProps } and
97
- * {@link ComponentClass.contextTypes contextTypes}.
115
+ * {@link FunctionComponent.defaultProps defaultProps }.
98
116
  *
99
117
  * @template P The props the component accepts.
100
118
  *
@@ -107,34 +125,18 @@ declare namespace React {
107
125
  * Represents any user-defined component, either as a function or a class.
108
126
  *
109
127
  * Similar to {@link ComponentType}, but without extra properties like
110
- * {@link FunctionComponent.defaultProps defaultProps } and
111
- * {@link ComponentClass.contextTypes contextTypes}.
128
+ * {@link FunctionComponent.defaultProps defaultProps }.
112
129
  *
113
130
  * @template P The props the component accepts.
114
131
  */
115
132
  type JSXElementConstructor<P> =
116
133
  | ((
117
134
  props: P,
118
- /**
119
- * @deprecated
120
- *
121
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components React Docs}
122
- */
123
- deprecatedLegacyContext?: any,
124
135
  ) => ReactElement<any, any> | null)
125
- | (new(
126
- props: P,
127
- /**
128
- * @deprecated
129
- *
130
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
131
- */
132
- deprecatedLegacyContext?: any,
133
- ) => Component<any, any>);
136
+ // constructor signature must match React.Component
137
+ | (new(props: P) => Component<any, any>);
134
138
 
135
139
  /**
136
- * A readonly ref container where {@link current} cannot be mutated.
137
- *
138
140
  * Created by {@link createRef}, or {@link useRef} when passed `null`.
139
141
  *
140
142
  * @template T The type of the ref's value.
@@ -151,7 +153,7 @@ declare namespace React {
151
153
  /**
152
154
  * The current value of the ref.
153
155
  */
154
- readonly current: T | null;
156
+ current: T;
155
157
  }
156
158
 
157
159
  interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
@@ -174,6 +176,7 @@ declare namespace React {
174
176
  instance: T | null,
175
177
  ):
176
178
  | void
179
+ | (() => VoidOrUndefinedOnly)
177
180
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[
178
181
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES
179
182
  ];
@@ -186,22 +189,15 @@ declare namespace React {
186
189
  * @see {@link RefObject}
187
190
  */
188
191
 
189
- type Ref<T> = RefCallback<T> | RefObject<T> | null;
192
+ type Ref<T> = RefCallback<T> | RefObject<T | null> | null;
190
193
  /**
191
- * A legacy implementation of refs where you can pass a string to a ref prop.
192
- *
193
- * @see {@link https://react.dev/reference/react/Component#refs React Docs}
194
- *
195
- * @example
196
- *
197
- * ```tsx
198
- * <div ref="myRef" />
199
- * ```
194
+ * @deprecated Use `Ref` instead. String refs are no longer supported.
195
+ * If you're typing a library with support for React versions with string refs, use `RefAttributes<T>['ref']` instead.
200
196
  */
201
- // TODO: Remove the string ref special case from `PropsWithRef` once we remove LegacyRef
202
- type LegacyRef<T> = string | Ref<T>;
203
-
197
+ type LegacyRef<T> = Ref<T>;
204
198
  /**
199
+ * @deprecated Use `ComponentRef<T>` instead
200
+ *
205
201
  * Retrieves the type of the 'ref' prop for a given component type or tag name.
206
202
  *
207
203
  * @template C The component type.
@@ -222,17 +218,9 @@ declare namespace React {
222
218
  C extends
223
219
  | ForwardRefExoticComponent<any>
224
220
  | { new(props: any): Component<any> }
225
- | ((props: any, deprecatedLegacyContext?: any) => ReactElement | null)
221
+ | ((props: any) => ReactElement | null)
226
222
  | keyof JSX.IntrinsicElements,
227
- > =
228
- // need to check first if `ref` is a valid prop for ts@3.0
229
- // otherwise it will infer `{}` instead of `never`
230
- "ref" extends keyof ComponentPropsWithRef<C>
231
- ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends RefAttributes<
232
- infer Instance
233
- >["ref"] ? Instance
234
- : never
235
- : never;
223
+ > = ComponentRef<C>;
236
224
 
237
225
  type ComponentState = any;
238
226
 
@@ -300,7 +288,7 @@ declare namespace React {
300
288
  *
301
289
  * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
302
290
  */
303
- ref?: LegacyRef<T> | undefined;
291
+ ref?: Ref<T> | undefined;
304
292
  }
305
293
 
306
294
  /**
@@ -325,7 +313,7 @@ declare namespace React {
325
313
  * ```
326
314
  */
327
315
  interface ReactElement<
328
- P = any,
316
+ P = unknown,
329
317
  T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
330
318
  > {
331
319
  type: T;
@@ -341,13 +329,28 @@ declare namespace React {
341
329
  P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
342
330
  > extends ReactElement<P, Exclude<T, number>> {}
343
331
 
332
+ /**
333
+ * @deprecated Use `ReactElement<P, React.FunctionComponent<P>>`
334
+ */
344
335
  interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
336
+ /**
337
+ * @deprecated Use `element.props.ref` instead.
338
+ */
345
339
  ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
346
340
  }
347
341
 
342
+ /**
343
+ * @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
344
+ */
348
345
  type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
346
+ /**
347
+ * @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
348
+ */
349
349
  interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
350
- ref?: LegacyRef<T> | undefined;
350
+ /**
351
+ * @deprecated Use `element.props.ref` instead.
352
+ */
353
+ ref?: Ref<T> | undefined;
351
354
  }
352
355
 
353
356
  /**
@@ -356,89 +359,34 @@ declare namespace React {
356
359
  type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
357
360
 
358
361
  // string fallback for custom web-components
362
+ /**
363
+ * @deprecated Use `ReactElement<P, string>`
364
+ */
359
365
  interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
360
366
  extends ReactElement<P, string>
361
367
  {
362
- ref: LegacyRef<T>;
368
+ /**
369
+ * @deprecated Use `element.props.ref` instead.
370
+ */
371
+ ref: Ref<T>;
363
372
  }
364
373
 
365
374
  // ReactHTML for ReactHTMLElement
366
375
  interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
367
376
 
368
377
  interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
369
- type: keyof ReactHTML;
378
+ type: HTMLElementType;
370
379
  }
371
380
 
372
381
  // ReactSVG for ReactSVGElement
373
382
  interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
374
- type: keyof ReactSVG;
383
+ type: SVGElementType;
375
384
  }
376
385
 
377
386
  interface ReactPortal extends ReactElement {
378
387
  children: ReactNode;
379
388
  }
380
389
 
381
- //
382
- // Factories
383
- // ----------------------------------------------------------------------
384
-
385
- type Factory<P> = (props?: Attributes & P, ...children: ReactNode[]) => ReactElement<P>;
386
-
387
- /**
388
- * @deprecated Please use `FunctionComponentFactory`
389
- */
390
- type SFCFactory<P> = FunctionComponentFactory<P>;
391
-
392
- type FunctionComponentFactory<P> = (
393
- props?: Attributes & P,
394
- ...children: ReactNode[]
395
- ) => FunctionComponentElement<P>;
396
-
397
- type ComponentFactory<P, T extends Component<P, ComponentState>> = (
398
- props?: ClassAttributes<T> & P,
399
- ...children: ReactNode[]
400
- ) => CElement<P, T>;
401
-
402
- type CFactory<P, T extends Component<P, ComponentState>> = ComponentFactory<P, T>;
403
- type ClassicFactory<P> = CFactory<P, ClassicComponent<P, ComponentState>>;
404
-
405
- type DOMFactory<P extends DOMAttributes<T>, T extends Element> = (
406
- props?: ClassAttributes<T> & P | null,
407
- ...children: ReactNode[]
408
- ) => DOMElement<P, T>;
409
-
410
- interface HTMLFactory<T extends HTMLElement> extends DetailedHTMLFactory<AllHTMLAttributes<T>, T> {}
411
-
412
- interface DetailedHTMLFactory<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMFactory<P, T> {
413
- (props?: ClassAttributes<T> & P | null, ...children: ReactNode[]): DetailedReactHTMLElement<P, T>;
414
- }
415
-
416
- interface SVGFactory extends DOMFactory<SVGAttributes<SVGElement>, SVGElement> {
417
- (
418
- props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null,
419
- ...children: ReactNode[]
420
- ): ReactSVGElement;
421
- }
422
-
423
- /**
424
- * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
425
- */
426
- type ReactText = string | number;
427
- /**
428
- * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
429
- */
430
- type ReactChild = ReactElement | string | number;
431
-
432
- /**
433
- * @deprecated Use either `ReactNode[]` if you need an array or `Iterable<ReactNode>` if its passed to a host component.
434
- */
435
- interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
436
- /**
437
- * WARNING: Not related to `React.Fragment`.
438
- * @deprecated This type is not relevant when using React. Inline the type instead to make the intent clear.
439
- */
440
- type ReactFragment = Iterable<ReactNode>;
441
-
442
390
  /**
443
391
  * For internal usage only.
444
392
  * Different release channels declare additional types of ReactNode this particular release channel accepts.
@@ -480,6 +428,7 @@ declare namespace React {
480
428
  | ReactElement
481
429
  | string
482
430
  | number
431
+ | bigint
483
432
  | Iterable<ReactNode>
484
433
  | ReactPortal
485
434
  | boolean
@@ -487,36 +436,13 @@ declare namespace React {
487
436
  | undefined
488
437
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
489
438
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
490
- ];
439
+ ]
440
+ | Promise<AwaitedReactNode>;
491
441
 
492
442
  //
493
443
  // Top Level API
494
444
  // ----------------------------------------------------------------------
495
445
 
496
- // DOM Elements
497
- /** @deprecated */
498
- function createFactory<T extends HTMLElement>(
499
- type: keyof ReactHTML,
500
- ): HTMLFactory<T>;
501
- /** @deprecated */
502
- function createFactory(
503
- type: keyof ReactSVG,
504
- ): SVGFactory;
505
- /** @deprecated */
506
- function createFactory<P extends DOMAttributes<T>, T extends Element>(
507
- type: string,
508
- ): DOMFactory<P, T>;
509
-
510
- // Custom components
511
- /** @deprecated */
512
- function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
513
- /** @deprecated */
514
- function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
515
- type: ClassType<P, T, C>,
516
- ): CFactory<P, T>;
517
- /** @deprecated */
518
- function createFactory<P>(type: ComponentClass<P>): Factory<P>;
519
-
520
446
  // DOM Elements
521
447
  // TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
522
448
  function createElement(
@@ -525,12 +451,12 @@ declare namespace React {
525
451
  ...children: ReactNode[]
526
452
  ): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
527
453
  function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
528
- type: keyof ReactHTML,
454
+ type: HTMLElementType,
529
455
  props?: ClassAttributes<T> & P | null,
530
456
  ...children: ReactNode[]
531
457
  ): DetailedReactHTMLElement<P, T>;
532
458
  function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
533
- type: keyof ReactSVG,
459
+ type: SVGElementType,
534
460
  props?: ClassAttributes<T> & P | null,
535
461
  ...children: ReactNode[]
536
462
  ): ReactSVGElement;
@@ -659,7 +585,6 @@ declare namespace React {
659
585
  * @template P The props the component accepts.
660
586
  */
661
587
  interface ProviderExoticComponent<P> extends ExoticComponent<P> {
662
- propTypes?: WeakValidationMap<P> | undefined;
663
588
  }
664
589
 
665
590
  /**
@@ -741,7 +666,7 @@ declare namespace React {
741
666
  * const ThemeContext = createContext('light');
742
667
  * ```
743
668
  */
744
- interface Context<T> {
669
+ interface Context<T> extends Provider<T> {
745
670
  Provider: Provider<T>;
746
671
  Consumer: Consumer<T>;
747
672
  /**
@@ -770,6 +695,13 @@ declare namespace React {
770
695
  * import { createContext } from 'react';
771
696
  *
772
697
  * const ThemeContext = createContext('light');
698
+ * function App() {
699
+ * return (
700
+ * <ThemeContext value="dark">
701
+ * <Toolbar />
702
+ * </ThemeContext>
703
+ * );
704
+ * }
773
705
  * ```
774
706
  */
775
707
  function createContext<T>(
@@ -780,9 +712,6 @@ declare namespace React {
780
712
 
781
713
  function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
782
714
 
783
- /**
784
- * Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
785
- */
786
715
  const Children: {
787
716
  map<T, C>(
788
717
  children: C | readonly C[],
@@ -988,6 +917,12 @@ declare namespace React {
988
917
  */
989
918
  static contextType?: Context<any> | undefined;
990
919
 
920
+ /**
921
+ * Ignored by React.
922
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
923
+ */
924
+ static propTypes?: any;
925
+
991
926
  /**
992
927
  * If using the new style context, re-declare this in your class to be the
993
928
  * `React.ContextType` of your `static contextType`.
@@ -1006,12 +941,8 @@ declare namespace React {
1006
941
  */
1007
942
  context: unknown;
1008
943
 
944
+ // Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
1009
945
  constructor(props: P);
1010
- /**
1011
- * @deprecated
1012
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}
1013
- */
1014
- constructor(props: P, context: any);
1015
946
 
1016
947
  // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
1017
948
  // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
@@ -1026,14 +957,6 @@ declare namespace React {
1026
957
 
1027
958
  readonly props: Readonly<P>;
1028
959
  state: Readonly<S>;
1029
- /**
1030
- * @deprecated
1031
- *
1032
- * @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
1033
- */
1034
- refs: {
1035
- [key: string]: ReactInstance;
1036
- };
1037
960
  }
1038
961
 
1039
962
  class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
@@ -1050,10 +973,6 @@ declare namespace React {
1050
973
  getInitialState?(): S;
1051
974
  }
1052
975
 
1053
- interface ChildContextProvider<CC> {
1054
- getChildContext(): CC;
1055
- }
1056
-
1057
976
  //
1058
977
  // Class Interfaces
1059
978
  // ----------------------------------------------------------------------
@@ -1118,58 +1037,12 @@ declare namespace React {
1118
1037
  * ```
1119
1038
  */
1120
1039
  interface FunctionComponent<P = {}> {
1121
- (
1122
- props: P,
1123
- /**
1124
- * @deprecated
1125
- *
1126
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1127
- */
1128
- deprecatedLegacyContext?: any,
1129
- ): ReactElement<any, any> | null;
1130
- /**
1131
- * Used to declare the types of the props accepted by the
1132
- * component. These types will be checked during rendering
1133
- * and in development only.
1134
- *
1135
- * We recommend using TypeScript instead of checking prop
1136
- * types at runtime.
1137
- *
1138
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1139
- */
1140
- propTypes?: WeakValidationMap<P> | undefined;
1040
+ (props: P): ReactElement<any, any> | null;
1141
1041
  /**
1142
- * @deprecated
1143
- *
1144
- * Lets you specify which legacy context is consumed by
1145
- * this component.
1146
- *
1147
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
1042
+ * Ignored by React.
1043
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1148
1044
  */
1149
- contextTypes?: ValidationMap<any> | undefined;
1150
- /**
1151
- * Used to define default values for the props accepted by
1152
- * the component.
1153
- *
1154
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1155
- *
1156
- * @example
1157
- *
1158
- * ```tsx
1159
- * type Props = { name?: string }
1160
- *
1161
- * const MyComponent: FC<Props> = (props) => {
1162
- * return <div>{props.name}</div>
1163
- * }
1164
- *
1165
- * MyComponent.defaultProps = {
1166
- * name: 'John Doe'
1167
- * }
1168
- * ```
1169
- *
1170
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1171
- */
1172
- defaultProps?: Partial<P> | undefined;
1045
+ propTypes?: any;
1173
1046
  /**
1174
1047
  * Used in debugging messages. You might want to set it
1175
1048
  * explicitly if you want to display a different name for
@@ -1191,38 +1064,6 @@ declare namespace React {
1191
1064
  displayName?: string | undefined;
1192
1065
  }
1193
1066
 
1194
- /**
1195
- * @deprecated - Equivalent to {@link React.FunctionComponent}.
1196
- *
1197
- * @see {@link React.FunctionComponent}
1198
- * @alias {@link VoidFunctionComponent}
1199
- */
1200
- type VFC<P = {}> = VoidFunctionComponent<P>;
1201
-
1202
- /**
1203
- * @deprecated - Equivalent to {@link React.FunctionComponent}.
1204
- *
1205
- * @see {@link React.FunctionComponent}
1206
- */
1207
- interface VoidFunctionComponent<P = {}> {
1208
- (
1209
- props: P,
1210
- /**
1211
- * @deprecated
1212
- *
1213
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1214
- */
1215
- deprecatedLegacyContext?: any,
1216
- ): ReactElement<any, any> | null;
1217
- propTypes?: WeakValidationMap<P> | undefined;
1218
- contextTypes?: ValidationMap<any> | undefined;
1219
- /**
1220
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1221
- */
1222
- defaultProps?: Partial<P> | undefined;
1223
- displayName?: string | undefined;
1224
- }
1225
-
1226
1067
  /**
1227
1068
  * The type of the ref received by a {@link ForwardRefRenderFunction}.
1228
1069
  *
@@ -1257,19 +1098,10 @@ declare namespace React {
1257
1098
  */
1258
1099
  displayName?: string | undefined;
1259
1100
  /**
1260
- * defaultProps are not supported on render functions passed to forwardRef.
1261
- *
1262
- * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
1263
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1101
+ * Ignored by React.
1102
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1264
1103
  */
1265
- defaultProps?: never | undefined;
1266
- /**
1267
- * propTypes are not supported on render functions passed to forwardRef.
1268
- *
1269
- * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
1270
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1271
- */
1272
- propTypes?: never | undefined;
1104
+ propTypes?: any;
1273
1105
  }
1274
1106
 
1275
1107
  /**
@@ -1279,48 +1111,14 @@ declare namespace React {
1279
1111
  * @template S The internal state of the component.
1280
1112
  */
1281
1113
  interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
1282
- new(
1283
- props: P,
1284
- /**
1285
- * @deprecated
1286
- *
1287
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1288
- */
1289
- deprecatedLegacyContext?: any,
1290
- ): Component<P, S>;
1114
+ // constructor signature must match React.Component
1115
+ new(props: P): Component<P, S>;
1291
1116
  /**
1292
- * Used to declare the types of the props accepted by the
1293
- * component. These types will be checked during rendering
1294
- * and in development only.
1295
- *
1296
- * We recommend using TypeScript instead of checking prop
1297
- * types at runtime.
1298
- *
1299
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1117
+ * Ignored by React.
1118
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1300
1119
  */
1301
- propTypes?: WeakValidationMap<P> | undefined;
1120
+ propTypes?: any;
1302
1121
  contextType?: Context<any> | undefined;
1303
- /**
1304
- * @deprecated use {@link ComponentClass.contextType} instead
1305
- *
1306
- * Lets you specify which legacy context is consumed by
1307
- * this component.
1308
- *
1309
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
1310
- */
1311
- contextTypes?: ValidationMap<any> | undefined;
1312
- /**
1313
- * @deprecated
1314
- *
1315
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
1316
- */
1317
- childContextTypes?: ValidationMap<any> | undefined;
1318
- /**
1319
- * Used to define default values for the props accepted by
1320
- * the component.
1321
- *
1322
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1323
- */
1324
1122
  defaultProps?: Partial<P> | undefined;
1325
1123
  /**
1326
1124
  * Used in debugging messages. You might want to set it
@@ -1339,7 +1137,7 @@ declare namespace React {
1339
1137
  * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
1340
1138
  */
1341
1139
  interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
1342
- new(props: P, deprecatedLegacyContext?: any): ClassicComponent<P, ComponentState>;
1140
+ new(props: P): ClassicComponent<P, ComponentState>;
1343
1141
  getDefaultProps?(): P;
1344
1142
  }
1345
1143
 
@@ -1354,7 +1152,7 @@ declare namespace React {
1354
1152
  */
1355
1153
  type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
1356
1154
  & C
1357
- & (new(props: P, deprecatedLegacyContext?: any) => T);
1155
+ & (new(props: P) => T);
1358
1156
 
1359
1157
  //
1360
1158
  // Component Specs and Lifecycle
@@ -1378,7 +1176,7 @@ declare namespace React {
1378
1176
  * If false is returned, {@link Component.render}, `componentWillUpdate`
1379
1177
  * and `componentDidUpdate` will not be called.
1380
1178
  */
1381
- shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean;
1179
+ shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): boolean;
1382
1180
  /**
1383
1181
  * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
1384
1182
  * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
@@ -1477,7 +1275,7 @@ declare namespace React {
1477
1275
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1478
1276
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1479
1277
  */
1480
- componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
1278
+ componentWillReceiveProps?(nextProps: Readonly<P>): void;
1481
1279
  /**
1482
1280
  * Called when the component may be receiving new props.
1483
1281
  * React may call this even if props have not changed, so be sure to compare new and existing
@@ -1495,7 +1293,7 @@ declare namespace React {
1495
1293
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1496
1294
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1497
1295
  */
1498
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
1296
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>): void;
1499
1297
  /**
1500
1298
  * Called immediately before rendering when new props or state is received. Not called for the initial render.
1501
1299
  *
@@ -1509,7 +1307,7 @@ declare namespace React {
1509
1307
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
1510
1308
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1511
1309
  */
1512
- componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
1310
+ componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
1513
1311
  /**
1514
1312
  * Called immediately before rendering when new props or state is received. Not called for the initial render.
1515
1313
  *
@@ -1525,41 +1323,10 @@ declare namespace React {
1525
1323
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
1526
1324
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1527
1325
  */
1528
- UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
1529
- }
1530
-
1531
- /**
1532
- * @deprecated
1533
- *
1534
- * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1535
- */
1536
- interface Mixin<P, S> extends ComponentLifecycle<P, S> {
1537
- mixins?: Array<Mixin<P, S>> | undefined;
1538
- statics?: {
1539
- [key: string]: any;
1540
- } | undefined;
1541
-
1542
- displayName?: string | undefined;
1543
- propTypes?: ValidationMap<any> | undefined;
1544
- contextTypes?: ValidationMap<any> | undefined;
1545
- childContextTypes?: ValidationMap<any> | undefined;
1546
-
1547
- getDefaultProps?(): P;
1548
- getInitialState?(): S;
1326
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
1549
1327
  }
1550
1328
 
1551
- /**
1552
- * @deprecated
1553
- *
1554
- * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1555
- */
1556
- interface ComponentSpec<P, S> extends Mixin<P, S> {
1557
- render(): ReactNode;
1558
-
1559
- [propertyName: string]: any;
1560
- }
1561
-
1562
- function createRef<T>(): RefObject<T>;
1329
+ function createRef<T>(): RefObject<T | null>;
1563
1330
 
1564
1331
  /**
1565
1332
  * The type of the component returned from {@link forwardRef}.
@@ -1570,10 +1337,10 @@ declare namespace React {
1570
1337
  */
1571
1338
  interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
1572
1339
  /**
1573
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1340
+ * Ignored by React.
1341
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1574
1342
  */
1575
- defaultProps?: Partial<P> | undefined;
1576
- propTypes?: WeakValidationMap<P> | undefined;
1343
+ propTypes?: any;
1577
1344
  }
1578
1345
 
1579
1346
  /**
@@ -1610,23 +1377,18 @@ declare namespace React {
1610
1377
  /**
1611
1378
  * Omits the 'ref' attribute from the given props object.
1612
1379
  *
1613
- * @template P The props object type.
1380
+ * @template Props The props object type.
1614
1381
  */
1615
- type PropsWithoutRef<P> =
1382
+ type PropsWithoutRef<Props> =
1616
1383
  // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
1617
1384
  // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
1618
1385
  // https://github.com/Microsoft/TypeScript/issues/28339
1619
- P extends any ? ("ref" extends keyof P ? Omit<P, "ref"> : P) : P;
1620
- /** Ensures that the props do not include string ref, which cannot be forwarded */
1621
- type PropsWithRef<P> =
1622
- // Note: String refs can be forwarded. We can't fix this bug without breaking a bunch of libraries now though.
1623
- // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
1624
- "ref" extends keyof P
1625
- ? P extends { ref?: infer R | undefined }
1626
- ? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
1627
- : P
1628
- : P
1629
- : P;
1386
+ Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
1387
+ /**
1388
+ * Ensures that the props do not include string ref, which cannot be forwarded
1389
+ * @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
1390
+ */
1391
+ type PropsWithRef<Props> = Props;
1630
1392
 
1631
1393
  type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
1632
1394
 
@@ -1658,7 +1420,7 @@ declare namespace React {
1658
1420
  * ```
1659
1421
  */
1660
1422
  type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
1661
- JSXElementConstructor<infer P> ? P
1423
+ JSXElementConstructor<infer Props> ? Props
1662
1424
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
1663
1425
  : {};
1664
1426
 
@@ -1685,9 +1447,11 @@ declare namespace React {
1685
1447
  * type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
1686
1448
  * ```
1687
1449
  */
1688
- type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
1689
- ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
1690
- : PropsWithRef<ComponentProps<T>>;
1450
+ type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
1451
+ // If it's a class i.e. newable we're dealing with a class component
1452
+ ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1453
+ : Props
1454
+ : ComponentProps<T>;
1691
1455
  /**
1692
1456
  * Used to retrieve the props a custom component accepts with its ref.
1693
1457
  *
@@ -1704,9 +1468,10 @@ declare namespace React {
1704
1468
  * type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
1705
1469
  * ```
1706
1470
  */
1707
- type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
1708
- ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
1709
- : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
1471
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
1472
+ // If it's a class i.e. newable we're dealing with a class component
1473
+ ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1474
+ : Props
1710
1475
  : never;
1711
1476
 
1712
1477
  /**
@@ -1734,10 +1499,24 @@ declare namespace React {
1734
1499
  */
1735
1500
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
1736
1501
 
1737
- type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
1738
- ComponentPropsWithoutRef<T> & RefAttributes<infer Method>
1739
- > ? Method
1740
- : ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1502
+ /**
1503
+ * Retrieves the type of the 'ref' prop for a given component type or tag name.
1504
+ *
1505
+ * @template C The component type.
1506
+ *
1507
+ * @example
1508
+ *
1509
+ * ```tsx
1510
+ * type MyComponentRef = React.ElementRef<typeof MyComponent>;
1511
+ * ```
1512
+ *
1513
+ * @example
1514
+ *
1515
+ * ```tsx
1516
+ * type DivRef = React.ElementRef<'div'>;
1517
+ * ```
1518
+ */
1519
+ type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1741
1520
  : never;
1742
1521
 
1743
1522
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
@@ -1838,6 +1617,11 @@ declare namespace React {
1838
1617
  * A {@link Dispatch} function can sometimes be called without any arguments.
1839
1618
  */
1840
1619
  type DispatchWithoutAction = () => void;
1620
+ // Limit the reducer to accept only 0 or 1 action arguments
1621
+ // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
1622
+ type AnyActionArg = [] | [any];
1623
+ // Get the dispatch type from the reducer arguments (captures optional action argument correctly)
1624
+ type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
1841
1625
  // Unlike redux, the actions _can_ be anything
1842
1626
  type Reducer<S, A> = (prevState: S, action: A) => S;
1843
1627
  // If useReducer accepts a reducer without action, dispatch may be called without any parameters.
@@ -1845,15 +1629,14 @@ declare namespace React {
1845
1629
  // types used to try and prevent the compiler from reducing S
1846
1630
  // to a supertype common with the second argument to useReducer()
1847
1631
  type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
1848
- type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
1849
- // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
1850
- type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
1851
- : never;
1852
1632
  type DependencyList = readonly unknown[];
1853
1633
 
1854
1634
  // NOTE: callbacks are _only_ allowed to return either void, or a destructor.
1855
1635
  type EffectCallback = () => void | Destructor;
1856
1636
 
1637
+ /**
1638
+ * @deprecated Use `RefObject` instead.
1639
+ */
1857
1640
  interface MutableRefObject<T> {
1858
1641
  current: T;
1859
1642
  }
@@ -1892,46 +1675,10 @@ declare namespace React {
1892
1675
  * @version 16.8.0
1893
1676
  * @see {@link https://react.dev/reference/react/useReducer}
1894
1677
  */
1895
- // overload where dispatch could accept 0 arguments.
1896
- function useReducer<R extends ReducerWithoutAction<any>, I>(
1897
- reducer: R,
1898
- initializerArg: I,
1899
- initializer: (arg: I) => ReducerStateWithoutAction<R>,
1900
- ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
1901
- /**
1902
- * An alternative to `useState`.
1903
- *
1904
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1905
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1906
- * updates because you can pass `dispatch` down instead of callbacks.
1907
- *
1908
- * @version 16.8.0
1909
- * @see {@link https://react.dev/reference/react/useReducer}
1910
- */
1911
- // overload where dispatch could accept 0 arguments.
1912
- function useReducer<R extends ReducerWithoutAction<any>>(
1913
- reducer: R,
1914
- initializerArg: ReducerStateWithoutAction<R>,
1915
- initializer?: undefined,
1916
- ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
1917
- /**
1918
- * An alternative to `useState`.
1919
- *
1920
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1921
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1922
- * updates because you can pass `dispatch` down instead of callbacks.
1923
- *
1924
- * @version 16.8.0
1925
- * @see {@link https://react.dev/reference/react/useReducer}
1926
- */
1927
- // overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
1928
- // If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
1929
- // the last overload effectively behaves as if the identity function (x => x) is the initializer.
1930
- function useReducer<R extends Reducer<any, any>, I>(
1931
- reducer: R,
1932
- initializerArg: I & ReducerState<R>,
1933
- initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
1934
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1678
+ function useReducer<S, A extends AnyActionArg>(
1679
+ reducer: (prevState: S, ...args: A) => S,
1680
+ initialState: S,
1681
+ ): [S, ActionDispatch<A>];
1935
1682
  /**
1936
1683
  * An alternative to `useState`.
1937
1684
  *
@@ -1942,12 +1689,10 @@ declare namespace React {
1942
1689
  * @version 16.8.0
1943
1690
  * @see {@link https://react.dev/reference/react/useReducer}
1944
1691
  */
1945
- // overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
1946
- function useReducer<R extends Reducer<any, any>, I>(
1947
- reducer: R,
1948
- initializerArg: I,
1949
- initializer: (arg: I) => ReducerState<R>,
1950
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1692
+ function useReducer<S, A extends AnyActionArg>(
1693
+ reducer: (prevState: S, ...args: A) => S,
1694
+ initialState: S,
1695
+ ): [S, ActionDispatch<A>];
1951
1696
  /**
1952
1697
  * An alternative to `useState`.
1953
1698
  *
@@ -1958,21 +1703,11 @@ declare namespace React {
1958
1703
  * @version 16.8.0
1959
1704
  * @see {@link https://react.dev/reference/react/useReducer}
1960
1705
  */
1961
-
1962
- // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.
1963
- // The Flow types do have an overload for 3-ary invocation with undefined initializer.
1964
-
1965
- // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common
1966
- // supertype between the reducer's return type and the initialState (or the initializer's return type),
1967
- // which would prevent autocompletion from ever working.
1968
-
1969
- // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
1970
- // in older versions, or a regression in newer versions of the typescript completion service.
1971
- function useReducer<R extends Reducer<any, any>>(
1972
- reducer: R,
1973
- initialState: ReducerState<R>,
1974
- initializer?: undefined,
1975
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1706
+ function useReducer<S, I, A extends AnyActionArg>(
1707
+ reducer: (prevState: S, ...args: A) => S,
1708
+ initialArg: I,
1709
+ init: (i: I) => S,
1710
+ ): [S, ActionDispatch<A>];
1976
1711
  /**
1977
1712
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1978
1713
  * (`initialValue`). The returned object will persist for the full lifetime of the component.
@@ -1983,7 +1718,7 @@ declare namespace React {
1983
1718
  * @version 16.8.0
1984
1719
  * @see {@link https://react.dev/reference/react/useRef}
1985
1720
  */
1986
- function useRef<T>(initialValue: T): MutableRefObject<T>;
1721
+ function useRef<T>(initialValue: T): RefObject<T>;
1987
1722
  // convenience overload for refs given as a ref prop as they typically start with a null value
1988
1723
  /**
1989
1724
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
@@ -1992,15 +1727,11 @@ declare namespace React {
1992
1727
  * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1993
1728
  * value around similar to how you’d use instance fields in classes.
1994
1729
  *
1995
- * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
1996
- * of the generic argument.
1997
- *
1998
1730
  * @version 16.8.0
1999
1731
  * @see {@link https://react.dev/reference/react/useRef}
2000
1732
  */
2001
- function useRef<T>(initialValue: T | null): RefObject<T>;
2002
- // convenience overload for potentially undefined initialValue / call with 0 arguments
2003
- // has a default to stop it from defaulting to {} instead
1733
+ function useRef<T>(initialValue: T | null): RefObject<T | null>;
1734
+ // convenience overload for undefined initialValue
2004
1735
  /**
2005
1736
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
2006
1737
  * (`initialValue`). The returned object will persist for the full lifetime of the component.
@@ -2011,7 +1742,7 @@ declare namespace React {
2011
1742
  * @version 16.8.0
2012
1743
  * @see {@link https://react.dev/reference/react/useRef}
2013
1744
  */
2014
- function useRef<T = undefined>(): MutableRefObject<T | undefined>;
1745
+ function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
2015
1746
  /**
2016
1747
  * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
2017
1748
  * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
@@ -2081,8 +1812,7 @@ declare namespace React {
2081
1812
  // it's just the function name without the "use" prefix.
2082
1813
  function useDebugValue<T>(value: T, format?: (value: T) => any): void;
2083
1814
 
2084
- // must be synchronous
2085
- export type TransitionFunction = () => VoidOrUndefinedOnly;
1815
+ export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
2086
1816
  // strange definition to allow vscode to show documentation on the invocation
2087
1817
  export interface TransitionStartFunction {
2088
1818
  /**
@@ -2090,7 +1820,7 @@ declare namespace React {
2090
1820
  *
2091
1821
  * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
2092
1822
  *
2093
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
1823
+ * @param callback A function which causes state updates that can be deferred.
2094
1824
  */
2095
1825
  (callback: TransitionFunction): void;
2096
1826
  }
@@ -2129,9 +1859,10 @@ declare namespace React {
2129
1859
  /**
2130
1860
  * Similar to `useTransition` but allows uses where hooks are not available.
2131
1861
  *
2132
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
1862
+ * @param callback A function which causes state updates that can be deferred.
2133
1863
  */
2134
1864
  export function startTransition(scope: TransitionFunction): void;
1865
+ export function startTransition(scope: TransitionFunction): void;
2135
1866
 
2136
1867
  /**
2137
1868
  * Wrap any code rendering and triggering updates to your components into `act()` calls.
@@ -2144,6 +1875,11 @@ declare namespace React {
2144
1875
  *
2145
1876
  * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
2146
1877
  */
1878
+ // NOTES
1879
+ // - the order of these signatures matters - typescript will check the signatures in source order.
1880
+ // If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
1881
+ // `strictNullChecks: false`.
1882
+ // - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
2147
1883
  // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
2148
1884
  export function act(callback: () => VoidOrUndefinedOnly): void;
2149
1885
  export function act<T>(callback: () => T | Promise<T>): Promise<T>;
@@ -2171,6 +1907,32 @@ declare namespace React {
2171
1907
  getServerSnapshot?: () => Snapshot,
2172
1908
  ): Snapshot;
2173
1909
 
1910
+ export function useOptimistic<State>(
1911
+ passthrough: State,
1912
+ ): [State, (action: State | ((pendingState: State) => State)) => void];
1913
+ export function useOptimistic<State, Action>(
1914
+ passthrough: State,
1915
+ reducer: (state: State, action: Action) => State,
1916
+ ): [State, (action: Action) => void];
1917
+
1918
+ export type Usable<T> = PromiseLike<T> | Context<T>;
1919
+
1920
+ export function use<T>(usable: Usable<T>): T;
1921
+
1922
+ export function useActionState<State>(
1923
+ action: (state: Awaited<State>) => State | Promise<State>,
1924
+ initialState: Awaited<State>,
1925
+ permalink?: string,
1926
+ ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
1927
+ export function useActionState<State, Payload>(
1928
+ action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
1929
+ initialState: Awaited<State>,
1930
+ permalink?: string,
1931
+ ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1932
+
1933
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1934
+ export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
1935
+
2174
1936
  //
2175
1937
  // Event System
2176
1938
  // ----------------------------------------------------------------------
@@ -2338,6 +2100,11 @@ declare namespace React {
2338
2100
  pseudoElement: string;
2339
2101
  }
2340
2102
 
2103
+ interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
2104
+ oldState: "closed" | "open";
2105
+ newState: "closed" | "open";
2106
+ }
2107
+
2341
2108
  interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
2342
2109
  elapsedTime: number;
2343
2110
  propertyName: string;
@@ -2365,6 +2132,7 @@ declare namespace React {
2365
2132
  type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
2366
2133
  type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
2367
2134
  type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
2135
+ type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
2368
2136
  type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
2369
2137
 
2370
2138
  //
@@ -2578,9 +2346,19 @@ declare namespace React {
2578
2346
  onAnimationIteration?: AnimationEventHandler<T> | undefined;
2579
2347
  onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
2580
2348
 
2349
+ // Toggle Events
2350
+ onToggle?: ToggleEventHandler<T> | undefined;
2351
+ onBeforeToggle?: ToggleEventHandler<T> | undefined;
2352
+
2581
2353
  // Transition Events
2354
+ onTransitionCancel?: TransitionEventHandler<T> | undefined;
2355
+ onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
2582
2356
  onTransitionEnd?: TransitionEventHandler<T> | undefined;
2583
2357
  onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
2358
+ onTransitionRun?: TransitionEventHandler<T> | undefined;
2359
+ onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
2360
+ onTransitionStart?: TransitionEventHandler<T> | undefined;
2361
+ onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
2584
2362
  }
2585
2363
 
2586
2364
  export interface CSSProperties extends CSS.Properties<string | number> {
@@ -2951,7 +2729,16 @@ declare namespace React {
2951
2729
  security?: string | undefined;
2952
2730
  unselectable?: "on" | "off" | undefined;
2953
2731
 
2732
+ // Popover API
2733
+ popover?: "" | "auto" | "manual" | undefined;
2734
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
2735
+ popoverTarget?: string | undefined;
2736
+
2954
2737
  // Living Standard
2738
+ /**
2739
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
2740
+ */
2741
+ inert?: boolean | undefined;
2955
2742
  /**
2956
2743
  * Hints at the type of data that might be entered by the user while editing the element or its contents
2957
2744
  * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
@@ -2978,6 +2765,7 @@ declare namespace React {
2978
2765
  action?:
2979
2766
  | string
2980
2767
  | undefined
2768
+ | ((formData: FormData) => void | Promise<void>)
2981
2769
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2982
2770
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2983
2771
  ];
@@ -3012,6 +2800,7 @@ declare namespace React {
3012
2800
  formAction?:
3013
2801
  | string
3014
2802
  | undefined
2803
+ | ((formData: FormData) => void | Promise<void>)
3015
2804
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3016
2805
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3017
2806
  ];
@@ -3144,6 +2933,7 @@ declare namespace React {
3144
2933
  form?: string | undefined;
3145
2934
  formAction?:
3146
2935
  | string
2936
+ | ((formData: FormData) => void | Promise<void>)
3147
2937
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3148
2938
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3149
2939
  ]
@@ -3177,7 +2967,6 @@ declare namespace React {
3177
2967
 
3178
2968
  interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
3179
2969
  open?: boolean | undefined;
3180
- onToggle?: ReactEventHandler<T> | undefined;
3181
2970
  name?: string | undefined;
3182
2971
  }
3183
2972
 
@@ -3210,6 +2999,7 @@ declare namespace React {
3210
2999
  action?:
3211
3000
  | string
3212
3001
  | undefined
3002
+ | ((formData: FormData) => void | Promise<void>)
3213
3003
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3214
3004
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3215
3005
  ];
@@ -3365,6 +3155,7 @@ declare namespace React {
3365
3155
  form?: string | undefined;
3366
3156
  formAction?:
3367
3157
  | string
3158
+ | ((formData: FormData) => void | Promise<void>)
3368
3159
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3369
3160
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3370
3161
  ]
@@ -3427,6 +3218,9 @@ declare namespace React {
3427
3218
  sizes?: string | undefined;
3428
3219
  type?: string | undefined;
3429
3220
  charSet?: string | undefined;
3221
+
3222
+ // React props
3223
+ precedence?: string | undefined;
3430
3224
  }
3431
3225
 
3432
3226
  interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3561,6 +3355,10 @@ declare namespace React {
3561
3355
  media?: string | undefined;
3562
3356
  scoped?: boolean | undefined;
3563
3357
  type?: string | undefined;
3358
+
3359
+ // React props
3360
+ href?: string | undefined;
3361
+ precedence?: string | undefined;
3564
3362
  }
3565
3363
 
3566
3364
  interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3948,259 +3746,184 @@ declare namespace React {
3948
3746
  webpreferences?: string | undefined;
3949
3747
  }
3950
3748
 
3951
- //
3952
- // React.DOM
3953
- // ----------------------------------------------------------------------
3954
-
3955
- interface ReactHTML {
3956
- a: DetailedHTMLFactory<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
3957
- abbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3958
- address: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3959
- area: DetailedHTMLFactory<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
3960
- article: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3961
- aside: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3962
- audio: DetailedHTMLFactory<AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
3963
- b: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3964
- base: DetailedHTMLFactory<BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
3965
- bdi: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3966
- bdo: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3967
- big: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3968
- blockquote: DetailedHTMLFactory<BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
3969
- body: DetailedHTMLFactory<HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
3970
- br: DetailedHTMLFactory<HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
3971
- button: DetailedHTMLFactory<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
3972
- canvas: DetailedHTMLFactory<CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
3973
- caption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3974
- center: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3975
- cite: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3976
- code: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3977
- col: DetailedHTMLFactory<ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3978
- colgroup: DetailedHTMLFactory<ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3979
- data: DetailedHTMLFactory<DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
3980
- datalist: DetailedHTMLFactory<HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
3981
- dd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3982
- del: DetailedHTMLFactory<DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
3983
- details: DetailedHTMLFactory<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
3984
- dfn: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3985
- dialog: DetailedHTMLFactory<DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
3986
- div: DetailedHTMLFactory<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
3987
- dl: DetailedHTMLFactory<HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
3988
- dt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3989
- em: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3990
- embed: DetailedHTMLFactory<EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
3991
- fieldset: DetailedHTMLFactory<FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
3992
- figcaption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3993
- figure: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3994
- footer: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3995
- form: DetailedHTMLFactory<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
3996
- h1: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3997
- h2: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3998
- h3: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3999
- h4: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4000
- h5: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4001
- h6: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4002
- head: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLHeadElement>;
4003
- header: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4004
- hgroup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4005
- hr: DetailedHTMLFactory<HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
4006
- html: DetailedHTMLFactory<HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
4007
- i: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4008
- iframe: DetailedHTMLFactory<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
4009
- img: DetailedHTMLFactory<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
4010
- input: DetailedHTMLFactory<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4011
- ins: DetailedHTMLFactory<InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
4012
- kbd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4013
- keygen: DetailedHTMLFactory<KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
4014
- label: DetailedHTMLFactory<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
4015
- legend: DetailedHTMLFactory<HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
4016
- li: DetailedHTMLFactory<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
4017
- link: DetailedHTMLFactory<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
4018
- main: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4019
- map: DetailedHTMLFactory<MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
4020
- mark: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4021
- menu: DetailedHTMLFactory<MenuHTMLAttributes<HTMLElement>, HTMLElement>;
4022
- menuitem: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4023
- meta: DetailedHTMLFactory<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
4024
- meter: DetailedHTMLFactory<MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
4025
- nav: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4026
- noscript: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4027
- object: DetailedHTMLFactory<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
4028
- ol: DetailedHTMLFactory<OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
4029
- optgroup: DetailedHTMLFactory<OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
4030
- option: DetailedHTMLFactory<OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
4031
- output: DetailedHTMLFactory<OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
4032
- p: DetailedHTMLFactory<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
4033
- param: DetailedHTMLFactory<ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
4034
- picture: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4035
- pre: DetailedHTMLFactory<HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
4036
- progress: DetailedHTMLFactory<ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
4037
- q: DetailedHTMLFactory<QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4038
- rp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4039
- rt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4040
- ruby: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4041
- s: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4042
- samp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4043
- search: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4044
- slot: DetailedHTMLFactory<SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
4045
- script: DetailedHTMLFactory<ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
4046
- section: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4047
- select: DetailedHTMLFactory<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
4048
- small: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4049
- source: DetailedHTMLFactory<SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
4050
- span: DetailedHTMLFactory<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
4051
- strong: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4052
- style: DetailedHTMLFactory<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
4053
- sub: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4054
- summary: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4055
- sup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4056
- table: DetailedHTMLFactory<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
4057
- template: DetailedHTMLFactory<HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
4058
- tbody: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4059
- td: DetailedHTMLFactory<TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
4060
- textarea: DetailedHTMLFactory<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
4061
- tfoot: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4062
- th: DetailedHTMLFactory<ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
4063
- thead: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4064
- time: DetailedHTMLFactory<TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
4065
- title: DetailedHTMLFactory<HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
4066
- tr: DetailedHTMLFactory<HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
4067
- track: DetailedHTMLFactory<TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
4068
- u: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4069
- ul: DetailedHTMLFactory<HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
4070
- "var": DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4071
- video: DetailedHTMLFactory<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
4072
- wbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4073
- webview: DetailedHTMLFactory<WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
4074
- }
4075
-
4076
- interface ReactSVG {
4077
- animate: SVGFactory;
4078
- circle: SVGFactory;
4079
- clipPath: SVGFactory;
4080
- defs: SVGFactory;
4081
- desc: SVGFactory;
4082
- ellipse: SVGFactory;
4083
- feBlend: SVGFactory;
4084
- feColorMatrix: SVGFactory;
4085
- feComponentTransfer: SVGFactory;
4086
- feComposite: SVGFactory;
4087
- feConvolveMatrix: SVGFactory;
4088
- feDiffuseLighting: SVGFactory;
4089
- feDisplacementMap: SVGFactory;
4090
- feDistantLight: SVGFactory;
4091
- feDropShadow: SVGFactory;
4092
- feFlood: SVGFactory;
4093
- feFuncA: SVGFactory;
4094
- feFuncB: SVGFactory;
4095
- feFuncG: SVGFactory;
4096
- feFuncR: SVGFactory;
4097
- feGaussianBlur: SVGFactory;
4098
- feImage: SVGFactory;
4099
- feMerge: SVGFactory;
4100
- feMergeNode: SVGFactory;
4101
- feMorphology: SVGFactory;
4102
- feOffset: SVGFactory;
4103
- fePointLight: SVGFactory;
4104
- feSpecularLighting: SVGFactory;
4105
- feSpotLight: SVGFactory;
4106
- feTile: SVGFactory;
4107
- feTurbulence: SVGFactory;
4108
- filter: SVGFactory;
4109
- foreignObject: SVGFactory;
4110
- g: SVGFactory;
4111
- image: SVGFactory;
4112
- line: SVGFactory;
4113
- linearGradient: SVGFactory;
4114
- marker: SVGFactory;
4115
- mask: SVGFactory;
4116
- metadata: SVGFactory;
4117
- path: SVGFactory;
4118
- pattern: SVGFactory;
4119
- polygon: SVGFactory;
4120
- polyline: SVGFactory;
4121
- radialGradient: SVGFactory;
4122
- rect: SVGFactory;
4123
- stop: SVGFactory;
4124
- svg: SVGFactory;
4125
- switch: SVGFactory;
4126
- symbol: SVGFactory;
4127
- text: SVGFactory;
4128
- textPath: SVGFactory;
4129
- tspan: SVGFactory;
4130
- use: SVGFactory;
4131
- view: SVGFactory;
4132
- }
4133
-
4134
- interface ReactDOM extends ReactHTML, ReactSVG {}
4135
-
4136
- //
4137
- // React.PropTypes
4138
- // ----------------------------------------------------------------------
4139
-
4140
- /**
4141
- * @deprecated Use `Validator` from the ´prop-types` instead.
4142
- */
4143
- type Validator<T> = PropTypes.Validator<T>;
4144
-
4145
- /**
4146
- * @deprecated Use `Requireable` from the ´prop-types` instead.
4147
- */
4148
- type Requireable<T> = PropTypes.Requireable<T>;
4149
-
4150
- /**
4151
- * @deprecated Use `ValidationMap` from the ´prop-types` instead.
4152
- */
4153
- type ValidationMap<T> = PropTypes.ValidationMap<T>;
4154
-
4155
- /**
4156
- * @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
4157
- */
4158
- type WeakValidationMap<T> = {
4159
- [K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
4160
- : undefined extends T[K] ? Validator<T[K] | null | undefined>
4161
- : Validator<T[K]>;
4162
- };
4163
-
4164
- /**
4165
- * @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
4166
- */
4167
- interface ReactPropTypes {
4168
- any: typeof PropTypes.any;
4169
- array: typeof PropTypes.array;
4170
- bool: typeof PropTypes.bool;
4171
- func: typeof PropTypes.func;
4172
- number: typeof PropTypes.number;
4173
- object: typeof PropTypes.object;
4174
- string: typeof PropTypes.string;
4175
- node: typeof PropTypes.node;
4176
- element: typeof PropTypes.element;
4177
- instanceOf: typeof PropTypes.instanceOf;
4178
- oneOf: typeof PropTypes.oneOf;
4179
- oneOfType: typeof PropTypes.oneOfType;
4180
- arrayOf: typeof PropTypes.arrayOf;
4181
- objectOf: typeof PropTypes.objectOf;
4182
- shape: typeof PropTypes.shape;
4183
- exact: typeof PropTypes.exact;
4184
- }
4185
-
4186
- //
4187
- // React.Children
4188
- // ----------------------------------------------------------------------
4189
-
4190
- /**
4191
- * @deprecated - Use `typeof React.Children` instead.
4192
- */
4193
- // Sync with type of `const Children`.
4194
- interface ReactChildren {
4195
- map<T, C>(
4196
- children: C | readonly C[],
4197
- fn: (child: C, index: number) => T,
4198
- ): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
4199
- forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
4200
- count(children: any): number;
4201
- only<C>(children: C): C extends any[] ? never : C;
4202
- toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
4203
- }
3749
+ // TODO: Move to react-dom
3750
+ type HTMLElementType =
3751
+ | "a"
3752
+ | "abbr"
3753
+ | "address"
3754
+ | "area"
3755
+ | "article"
3756
+ | "aside"
3757
+ | "audio"
3758
+ | "b"
3759
+ | "base"
3760
+ | "bdi"
3761
+ | "bdo"
3762
+ | "big"
3763
+ | "blockquote"
3764
+ | "body"
3765
+ | "br"
3766
+ | "button"
3767
+ | "canvas"
3768
+ | "caption"
3769
+ | "center"
3770
+ | "cite"
3771
+ | "code"
3772
+ | "col"
3773
+ | "colgroup"
3774
+ | "data"
3775
+ | "datalist"
3776
+ | "dd"
3777
+ | "del"
3778
+ | "details"
3779
+ | "dfn"
3780
+ | "dialog"
3781
+ | "div"
3782
+ | "dl"
3783
+ | "dt"
3784
+ | "em"
3785
+ | "embed"
3786
+ | "fieldset"
3787
+ | "figcaption"
3788
+ | "figure"
3789
+ | "footer"
3790
+ | "form"
3791
+ | "h1"
3792
+ | "h2"
3793
+ | "h3"
3794
+ | "h4"
3795
+ | "h5"
3796
+ | "h6"
3797
+ | "head"
3798
+ | "header"
3799
+ | "hgroup"
3800
+ | "hr"
3801
+ | "html"
3802
+ | "i"
3803
+ | "iframe"
3804
+ | "img"
3805
+ | "input"
3806
+ | "ins"
3807
+ | "kbd"
3808
+ | "keygen"
3809
+ | "label"
3810
+ | "legend"
3811
+ | "li"
3812
+ | "link"
3813
+ | "main"
3814
+ | "map"
3815
+ | "mark"
3816
+ | "menu"
3817
+ | "menuitem"
3818
+ | "meta"
3819
+ | "meter"
3820
+ | "nav"
3821
+ | "noscript"
3822
+ | "object"
3823
+ | "ol"
3824
+ | "optgroup"
3825
+ | "option"
3826
+ | "output"
3827
+ | "p"
3828
+ | "param"
3829
+ | "picture"
3830
+ | "pre"
3831
+ | "progress"
3832
+ | "q"
3833
+ | "rp"
3834
+ | "rt"
3835
+ | "ruby"
3836
+ | "s"
3837
+ | "samp"
3838
+ | "search"
3839
+ | "slot"
3840
+ | "script"
3841
+ | "section"
3842
+ | "select"
3843
+ | "small"
3844
+ | "source"
3845
+ | "span"
3846
+ | "strong"
3847
+ | "style"
3848
+ | "sub"
3849
+ | "summary"
3850
+ | "sup"
3851
+ | "table"
3852
+ | "template"
3853
+ | "tbody"
3854
+ | "td"
3855
+ | "textarea"
3856
+ | "tfoot"
3857
+ | "th"
3858
+ | "thead"
3859
+ | "time"
3860
+ | "title"
3861
+ | "tr"
3862
+ | "track"
3863
+ | "u"
3864
+ | "ul"
3865
+ | "var"
3866
+ | "video"
3867
+ | "wbr"
3868
+ | "webview";
3869
+
3870
+ // TODO: Move to react-dom
3871
+ type SVGElementType =
3872
+ | "animate"
3873
+ | "circle"
3874
+ | "clipPath"
3875
+ | "defs"
3876
+ | "desc"
3877
+ | "ellipse"
3878
+ | "feBlend"
3879
+ | "feColorMatrix"
3880
+ | "feComponentTransfer"
3881
+ | "feComposite"
3882
+ | "feConvolveMatrix"
3883
+ | "feDiffuseLighting"
3884
+ | "feDisplacementMap"
3885
+ | "feDistantLight"
3886
+ | "feDropShadow"
3887
+ | "feFlood"
3888
+ | "feFuncA"
3889
+ | "feFuncB"
3890
+ | "feFuncG"
3891
+ | "feFuncR"
3892
+ | "feGaussianBlur"
3893
+ | "feImage"
3894
+ | "feMerge"
3895
+ | "feMergeNode"
3896
+ | "feMorphology"
3897
+ | "feOffset"
3898
+ | "fePointLight"
3899
+ | "feSpecularLighting"
3900
+ | "feSpotLight"
3901
+ | "feTile"
3902
+ | "feTurbulence"
3903
+ | "filter"
3904
+ | "foreignObject"
3905
+ | "g"
3906
+ | "image"
3907
+ | "line"
3908
+ | "linearGradient"
3909
+ | "marker"
3910
+ | "mask"
3911
+ | "metadata"
3912
+ | "path"
3913
+ | "pattern"
3914
+ | "polygon"
3915
+ | "polyline"
3916
+ | "radialGradient"
3917
+ | "rect"
3918
+ | "stop"
3919
+ | "svg"
3920
+ | "switch"
3921
+ | "symbol"
3922
+ | "text"
3923
+ | "textPath"
3924
+ | "tspan"
3925
+ | "use"
3926
+ | "view";
4204
3927
 
4205
3928
  //
4206
3929
  // Browser Interfaces
@@ -4242,67 +3965,6 @@ declare namespace React {
4242
3965
  }
4243
3966
 
4244
3967
  // Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
4245
- namespace JSX {
4246
- interface Element extends GlobalJSXElement {}
4247
- interface ElementClass extends GlobalJSXElementClass {}
4248
- interface ElementAttributesProperty extends GlobalJSXElementAttributesProperty {}
4249
- interface ElementChildrenAttribute extends GlobalJSXElementChildrenAttribute {}
4250
-
4251
- type LibraryManagedAttributes<C, P> = GlobalJSXLibraryManagedAttributes<C, P>;
4252
-
4253
- interface IntrinsicAttributes extends GlobalJSXIntrinsicAttributes {}
4254
- interface IntrinsicClassAttributes<T> extends GlobalJSXIntrinsicClassAttributes<T> {}
4255
- interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
4256
- }
4257
- }
4258
-
4259
- // naked 'any' type in a conditional type will short circuit and union both the then/else branches
4260
- // so boolean is only resolved for T = any
4261
- type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
4262
-
4263
- type ExactlyAnyPropertyKeys<T> = { [K in keyof T]: IsExactlyAny<T[K]> extends true ? K : never }[keyof T];
4264
- type NotExactlyAnyPropertyKeys<T> = Exclude<keyof T, ExactlyAnyPropertyKeys<T>>;
4265
-
4266
- // Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any
4267
- type MergePropTypes<P, T> =
4268
- // Distribute over P in case it is a union type
4269
- P extends any
4270
- // If props is type any, use propTypes definitions
4271
- ? IsExactlyAny<P> extends true ? T
4272
- // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
4273
- : string extends keyof P ? P
4274
- // Prefer declared types which are not exactly any
4275
- :
4276
- & Pick<P, NotExactlyAnyPropertyKeys<P>>
4277
- // For props which are exactly any, use the type inferred from propTypes if present
4278
- & Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
4279
- // Keep leftover props not specified in propTypes
4280
- & Pick<P, Exclude<keyof P, keyof T>>
4281
- : never;
4282
-
4283
- type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4284
-
4285
- // Any prop that has a default prop becomes optional, but its type is unchanged
4286
- // Undeclared default props are augmented into the resulting allowable attributes
4287
- // If declared props have indexed properties, ignore default props entirely as keyof gets widened
4288
- // Wrap in an outer-level conditional type to allow distribution over props that are unions
4289
- type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4290
- :
4291
- & Pick<P, Exclude<keyof P, keyof D>>
4292
- & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4293
- & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4294
- : never;
4295
-
4296
- type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D }
4297
- ? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
4298
- : C extends { propTypes: infer T } ? MergePropTypes<P, PropTypes.InferProps<T>>
4299
- : C extends { defaultProps: infer D } ? Defaultize<P, D>
4300
- : P;
4301
-
4302
- declare global {
4303
- /**
4304
- * @deprecated Use `React.JSX` instead of the global `JSX` namespace.
4305
- */
4306
3968
  namespace JSX {
4307
3969
  interface Element extends React.ReactElement<any, any> {}
4308
3970
  interface ElementClass extends React.Component<any> {
@@ -4514,17 +4176,18 @@ declare global {
4514
4176
  }
4515
4177
  }
4516
4178
 
4517
- // React.JSX needs to point to global.JSX to keep global module augmentations intact.
4518
- // But we can't access global.JSX so we need to create these aliases instead.
4519
- // Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
4520
- interface GlobalJSXElement extends JSX.Element {}
4521
- interface GlobalJSXElementClass extends JSX.ElementClass {}
4522
- interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
4523
- interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
4524
-
4525
- type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
4179
+ type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4526
4180
 
4527
- interface GlobalJSXIntrinsicAttributes extends JSX.IntrinsicAttributes {}
4528
- interface GlobalJSXIntrinsicClassAttributes<T> extends JSX.IntrinsicClassAttributes<T> {}
4181
+ // Any prop that has a default prop becomes optional, but its type is unchanged
4182
+ // Undeclared default props are augmented into the resulting allowable attributes
4183
+ // If declared props have indexed properties, ignore default props entirely as keyof gets widened
4184
+ // Wrap in an outer-level conditional type to allow distribution over props that are unions
4185
+ type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4186
+ :
4187
+ & Pick<P, Exclude<keyof P, keyof D>>
4188
+ & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4189
+ & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4190
+ : never;
4529
4191
 
4530
- interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}
4192
+ type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
4193
+ : P;