@types/react 18.3.1 → 19.2.8

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,17 +5,18 @@
5
5
  /// <reference path="global.d.ts" />
6
6
 
7
7
  import * as CSS from "csstype";
8
- import * as PropTypes from "prop-types";
9
8
 
10
9
  type NativeAnimationEvent = AnimationEvent;
11
10
  type NativeClipboardEvent = ClipboardEvent;
12
11
  type NativeCompositionEvent = CompositionEvent;
13
12
  type NativeDragEvent = DragEvent;
14
13
  type NativeFocusEvent = FocusEvent;
14
+ type NativeInputEvent = InputEvent;
15
15
  type NativeKeyboardEvent = KeyboardEvent;
16
16
  type NativeMouseEvent = MouseEvent;
17
17
  type NativeTouchEvent = TouchEvent;
18
18
  type NativePointerEvent = PointerEvent;
19
+ type NativeToggleEvent = ToggleEvent;
19
20
  type NativeTransitionEvent = TransitionEvent;
20
21
  type NativeUIEvent = UIEvent;
21
22
  type NativeWheelEvent = WheelEvent;
@@ -33,6 +34,25 @@ type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
33
34
 
34
35
  declare const UNDEFINED_VOID_ONLY: unique symbol;
35
36
 
37
+ /**
38
+ * @internal Use `Awaited<ReactNode>` instead
39
+ */
40
+ // Helper type to enable `Awaited<ReactNode>`.
41
+ // Must be a copy of the non-thenables of `ReactNode`.
42
+ type AwaitedReactNode =
43
+ | React.ReactElement
44
+ | string
45
+ | number
46
+ | bigint
47
+ | Iterable<React.ReactNode>
48
+ | React.ReactPortal
49
+ | boolean
50
+ | null
51
+ | undefined
52
+ | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
53
+ keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
54
+ ];
55
+
36
56
  /**
37
57
  * The function returned from an effect passed to {@link React.useEffect useEffect},
38
58
  * which can be used to clean up the effect when the component unmounts.
@@ -93,8 +113,7 @@ declare namespace React {
93
113
  * Represents any user-defined component, either as a function or a class.
94
114
  *
95
115
  * Similar to {@link JSXElementConstructor}, but with extra properties like
96
- * {@link FunctionComponent.defaultProps defaultProps } and
97
- * {@link ComponentClass.contextTypes contextTypes}.
116
+ * {@link FunctionComponent.defaultProps defaultProps }.
98
117
  *
99
118
  * @template P The props the component accepts.
100
119
  *
@@ -107,34 +126,18 @@ declare namespace React {
107
126
  * Represents any user-defined component, either as a function or a class.
108
127
  *
109
128
  * Similar to {@link ComponentType}, but without extra properties like
110
- * {@link FunctionComponent.defaultProps defaultProps } and
111
- * {@link ComponentClass.contextTypes contextTypes}.
129
+ * {@link FunctionComponent.defaultProps defaultProps }.
112
130
  *
113
131
  * @template P The props the component accepts.
114
132
  */
115
133
  type JSXElementConstructor<P> =
116
134
  | ((
117
135
  props: P,
118
- /**
119
- * @deprecated
120
- *
121
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components React Docs}
122
- */
123
- deprecatedLegacyContext?: any,
124
136
  ) => ReactElement<any, any> | null)
125
- | (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>);
137
+ // constructor signature must match React.Component
138
+ | (new(props: P, context: any) => Component<any, any>);
134
139
 
135
140
  /**
136
- * A readonly ref container where {@link current} cannot be mutated.
137
- *
138
141
  * Created by {@link createRef}, or {@link useRef} when passed `null`.
139
142
  *
140
143
  * @template T The type of the ref's value.
@@ -151,7 +154,7 @@ declare namespace React {
151
154
  /**
152
155
  * The current value of the ref.
153
156
  */
154
- readonly current: T | null;
157
+ current: T;
155
158
  }
156
159
 
157
160
  interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
@@ -174,6 +177,7 @@ declare namespace React {
174
177
  instance: T | null,
175
178
  ):
176
179
  | void
180
+ | (() => VoidOrUndefinedOnly)
177
181
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[
178
182
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES
179
183
  ];
@@ -186,22 +190,15 @@ declare namespace React {
186
190
  * @see {@link RefObject}
187
191
  */
188
192
 
189
- type Ref<T> = RefCallback<T> | RefObject<T> | null;
193
+ type Ref<T> = RefCallback<T> | RefObject<T | null> | null;
190
194
  /**
191
- * 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
- * ```
195
+ * @deprecated Use `Ref` instead. String refs are no longer supported.
196
+ * If you're typing a library with support for React versions with string refs, use `RefAttributes<T>['ref']` instead.
200
197
  */
201
- // TODO: Remove the string ref special case from `PropsWithRef` once we remove LegacyRef
202
- type LegacyRef<T> = string | Ref<T>;
203
-
198
+ type LegacyRef<T> = Ref<T>;
204
199
  /**
200
+ * @deprecated Use `ComponentRef<T>` instead
201
+ *
205
202
  * Retrieves the type of the 'ref' prop for a given component type or tag name.
206
203
  *
207
204
  * @template C The component type.
@@ -221,18 +218,10 @@ declare namespace React {
221
218
  type ElementRef<
222
219
  C extends
223
220
  | ForwardRefExoticComponent<any>
224
- | { new(props: any): Component<any> }
225
- | ((props: any, deprecatedLegacyContext?: any) => ReactElement | null)
221
+ | { new(props: any, context: any): Component<any> }
222
+ | ((props: any) => ReactElement | null)
226
223
  | keyof JSX.IntrinsicElements,
227
- > =
228
- // need to check first if `ref` is a valid prop for ts@3.0
229
- // otherwise it will infer `{}` instead of `never`
230
- "ref" extends keyof ComponentPropsWithRef<C>
231
- ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends RefAttributes<
232
- infer Instance
233
- >["ref"] ? Instance
234
- : never
235
- : never;
224
+ > = ComponentRef<C>;
236
225
 
237
226
  type ComponentState = any;
238
227
 
@@ -300,7 +289,7 @@ declare namespace React {
300
289
  *
301
290
  * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
302
291
  */
303
- ref?: LegacyRef<T> | undefined;
292
+ ref?: Ref<T> | undefined;
304
293
  }
305
294
 
306
295
  /**
@@ -325,7 +314,7 @@ declare namespace React {
325
314
  * ```
326
315
  */
327
316
  interface ReactElement<
328
- P = any,
317
+ P = unknown,
329
318
  T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
330
319
  > {
331
320
  type: T;
@@ -341,13 +330,28 @@ declare namespace React {
341
330
  P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
342
331
  > extends ReactElement<P, Exclude<T, number>> {}
343
332
 
333
+ /**
334
+ * @deprecated Use `ReactElement<P, React.FunctionComponent<P>>`
335
+ */
344
336
  interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
337
+ /**
338
+ * @deprecated Use `element.props.ref` instead.
339
+ */
345
340
  ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
346
341
  }
347
342
 
343
+ /**
344
+ * @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
345
+ */
348
346
  type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
347
+ /**
348
+ * @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
349
+ */
349
350
  interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
350
- ref?: LegacyRef<T> | undefined;
351
+ /**
352
+ * @deprecated Use `element.props.ref` instead.
353
+ */
354
+ ref?: Ref<T> | undefined;
351
355
  }
352
356
 
353
357
  /**
@@ -356,89 +360,34 @@ declare namespace React {
356
360
  type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
357
361
 
358
362
  // string fallback for custom web-components
363
+ /**
364
+ * @deprecated Use `ReactElement<P, string>`
365
+ */
359
366
  interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
360
367
  extends ReactElement<P, string>
361
368
  {
362
- ref: LegacyRef<T>;
369
+ /**
370
+ * @deprecated Use `element.props.ref` instead.
371
+ */
372
+ ref: Ref<T>;
363
373
  }
364
374
 
365
375
  // ReactHTML for ReactHTMLElement
366
376
  interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
367
377
 
368
378
  interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
369
- type: keyof ReactHTML;
379
+ type: HTMLElementType;
370
380
  }
371
381
 
372
382
  // ReactSVG for ReactSVGElement
373
383
  interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
374
- type: keyof ReactSVG;
384
+ type: SVGElementType;
375
385
  }
376
386
 
377
387
  interface ReactPortal extends ReactElement {
378
388
  children: ReactNode;
379
389
  }
380
390
 
381
- //
382
- // Factories
383
- // ----------------------------------------------------------------------
384
-
385
- type Factory<P> = (props?: Attributes & P, ...children: ReactNode[]) => ReactElement<P>;
386
-
387
- /**
388
- * @deprecated Please use `FunctionComponentFactory`
389
- */
390
- type SFCFactory<P> = FunctionComponentFactory<P>;
391
-
392
- type FunctionComponentFactory<P> = (
393
- props?: Attributes & P,
394
- ...children: ReactNode[]
395
- ) => FunctionComponentElement<P>;
396
-
397
- type ComponentFactory<P, T extends Component<P, ComponentState>> = (
398
- props?: ClassAttributes<T> & P,
399
- ...children: ReactNode[]
400
- ) => CElement<P, T>;
401
-
402
- type CFactory<P, T extends Component<P, ComponentState>> = ComponentFactory<P, T>;
403
- type ClassicFactory<P> = CFactory<P, ClassicComponent<P, ComponentState>>;
404
-
405
- type DOMFactory<P extends DOMAttributes<T>, T extends Element> = (
406
- props?: ClassAttributes<T> & P | null,
407
- ...children: ReactNode[]
408
- ) => DOMElement<P, T>;
409
-
410
- interface HTMLFactory<T extends HTMLElement> extends DetailedHTMLFactory<AllHTMLAttributes<T>, T> {}
411
-
412
- interface DetailedHTMLFactory<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMFactory<P, T> {
413
- (props?: ClassAttributes<T> & P | null, ...children: ReactNode[]): DetailedReactHTMLElement<P, T>;
414
- }
415
-
416
- interface SVGFactory extends DOMFactory<SVGAttributes<SVGElement>, SVGElement> {
417
- (
418
- props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null,
419
- ...children: ReactNode[]
420
- ): ReactSVGElement;
421
- }
422
-
423
- /**
424
- * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
425
- */
426
- type ReactText = string | number;
427
- /**
428
- * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
429
- */
430
- type ReactChild = ReactElement | string | number;
431
-
432
- /**
433
- * @deprecated Use either `ReactNode[]` if you need an array or `Iterable<ReactNode>` if its passed to a host component.
434
- */
435
- interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
436
- /**
437
- * WARNING: Not related to `React.Fragment`.
438
- * @deprecated This type is not relevant when using React. Inline the type instead to make the intent clear.
439
- */
440
- type ReactFragment = Iterable<ReactNode>;
441
-
442
391
  /**
443
392
  * For internal usage only.
444
393
  * Different release channels declare additional types of ReactNode this particular release channel accepts.
@@ -480,6 +429,7 @@ declare namespace React {
480
429
  | ReactElement
481
430
  | string
482
431
  | number
432
+ | bigint
483
433
  | Iterable<ReactNode>
484
434
  | ReactPortal
485
435
  | boolean
@@ -487,36 +437,13 @@ declare namespace React {
487
437
  | undefined
488
438
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
489
439
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
490
- ];
440
+ ]
441
+ | Promise<AwaitedReactNode>;
491
442
 
492
443
  //
493
444
  // Top Level API
494
445
  // ----------------------------------------------------------------------
495
446
 
496
- // DOM Elements
497
- /** @deprecated */
498
- function createFactory<T extends HTMLElement>(
499
- type: keyof ReactHTML,
500
- ): HTMLFactory<T>;
501
- /** @deprecated */
502
- function createFactory(
503
- type: keyof ReactSVG,
504
- ): SVGFactory;
505
- /** @deprecated */
506
- function createFactory<P extends DOMAttributes<T>, T extends Element>(
507
- type: string,
508
- ): DOMFactory<P, T>;
509
-
510
- // Custom components
511
- /** @deprecated */
512
- function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
513
- /** @deprecated */
514
- function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
515
- type: ClassType<P, T, C>,
516
- ): CFactory<P, T>;
517
- /** @deprecated */
518
- function createFactory<P>(type: ComponentClass<P>): Factory<P>;
519
-
520
447
  // DOM Elements
521
448
  // TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
522
449
  function createElement(
@@ -525,12 +452,12 @@ declare namespace React {
525
452
  ...children: ReactNode[]
526
453
  ): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
527
454
  function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
528
- type: keyof ReactHTML,
455
+ type: HTMLElementType,
529
456
  props?: ClassAttributes<T> & P | null,
530
457
  ...children: ReactNode[]
531
458
  ): DetailedReactHTMLElement<P, T>;
532
459
  function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
533
- type: keyof ReactSVG,
460
+ type: SVGElementType,
534
461
  props?: ClassAttributes<T> & P | null,
535
462
  ...children: ReactNode[]
536
463
  ): ReactSVGElement;
@@ -659,7 +586,6 @@ declare namespace React {
659
586
  * @template P The props the component accepts.
660
587
  */
661
588
  interface ProviderExoticComponent<P> extends ExoticComponent<P> {
662
- propTypes?: WeakValidationMap<P> | undefined;
663
589
  }
664
590
 
665
591
  /**
@@ -741,7 +667,7 @@ declare namespace React {
741
667
  * const ThemeContext = createContext('light');
742
668
  * ```
743
669
  */
744
- interface Context<T> {
670
+ interface Context<T> extends Provider<T> {
745
671
  Provider: Provider<T>;
746
672
  Consumer: Consumer<T>;
747
673
  /**
@@ -770,6 +696,13 @@ declare namespace React {
770
696
  * import { createContext } from 'react';
771
697
  *
772
698
  * const ThemeContext = createContext('light');
699
+ * function App() {
700
+ * return (
701
+ * <ThemeContext value="dark">
702
+ * <Toolbar />
703
+ * </ThemeContext>
704
+ * );
705
+ * }
773
706
  * ```
774
707
  */
775
708
  function createContext<T>(
@@ -780,9 +713,6 @@ declare namespace React {
780
713
 
781
714
  function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
782
715
 
783
- /**
784
- * Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
785
- */
786
716
  const Children: {
787
717
  map<T, C>(
788
718
  children: C | readonly C[],
@@ -793,6 +723,10 @@ declare namespace React {
793
723
  only<C>(children: C): C extends any[] ? never : C;
794
724
  toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
795
725
  };
726
+
727
+ export interface FragmentProps {
728
+ children?: React.ReactNode;
729
+ }
796
730
  /**
797
731
  * Lets you group elements without a wrapper node.
798
732
  *
@@ -820,7 +754,7 @@ declare namespace React {
820
754
  * </>
821
755
  * ```
822
756
  */
823
- const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
757
+ const Fragment: ExoticComponent<FragmentProps>;
824
758
 
825
759
  /**
826
760
  * Lets you find common bugs in your components early during development.
@@ -849,6 +783,12 @@ declare namespace React {
849
783
 
850
784
  /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
851
785
  fallback?: ReactNode;
786
+
787
+ /**
788
+ * A name for this Suspense boundary for instrumentation purposes.
789
+ * The name will help identify this boundary in React DevTools.
790
+ */
791
+ name?: string | undefined;
852
792
  }
853
793
 
854
794
  /**
@@ -983,7 +923,13 @@ declare namespace React {
983
923
  static contextType?: Context<any> | undefined;
984
924
 
985
925
  /**
986
- * If using the new style context, re-declare this in your class to be the
926
+ * Ignored by React.
927
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
928
+ */
929
+ static propTypes?: any;
930
+
931
+ /**
932
+ * If using React Context, re-declare this in your class to be the
987
933
  * `React.ContextType` of your `static contextType`.
988
934
  * Should be used with type annotation or static contextType.
989
935
  *
@@ -1000,11 +946,15 @@ declare namespace React {
1000
946
  */
1001
947
  context: unknown;
1002
948
 
949
+ // Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
1003
950
  constructor(props: P);
1004
951
  /**
1005
- * @deprecated
1006
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}
952
+ * @param props
953
+ * @param context value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
954
+ * in `contextType`.
1007
955
  */
956
+ // TODO: Ideally we'd infer the constructor signatur from `contextType`.
957
+ // Might be hard to ship without breaking existing code.
1008
958
  constructor(props: P, context: any);
1009
959
 
1010
960
  // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
@@ -1020,14 +970,6 @@ declare namespace React {
1020
970
 
1021
971
  readonly props: Readonly<P>;
1022
972
  state: Readonly<S>;
1023
- /**
1024
- * @deprecated
1025
- *
1026
- * @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
1027
- */
1028
- refs: {
1029
- [key: string]: ReactInstance;
1030
- };
1031
973
  }
1032
974
 
1033
975
  class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
@@ -1044,10 +986,6 @@ declare namespace React {
1044
986
  getInitialState?(): S;
1045
987
  }
1046
988
 
1047
- interface ChildContextProvider<CC> {
1048
- getChildContext(): CC;
1049
- }
1050
-
1051
989
  //
1052
990
  // Class Interfaces
1053
991
  // ----------------------------------------------------------------------
@@ -1112,58 +1050,12 @@ declare namespace React {
1112
1050
  * ```
1113
1051
  */
1114
1052
  interface FunctionComponent<P = {}> {
1115
- (
1116
- props: P,
1117
- /**
1118
- * @deprecated
1119
- *
1120
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1121
- */
1122
- deprecatedLegacyContext?: any,
1123
- ): ReactElement<any, any> | null;
1124
- /**
1125
- * Used to declare the types of the props accepted by the
1126
- * component. These types will be checked during rendering
1127
- * and in development only.
1128
- *
1129
- * We recommend using TypeScript instead of checking prop
1130
- * types at runtime.
1131
- *
1132
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1133
- */
1134
- propTypes?: WeakValidationMap<P> | undefined;
1135
- /**
1136
- * @deprecated
1137
- *
1138
- * Lets you specify which legacy context is consumed by
1139
- * this component.
1140
- *
1141
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
1142
- */
1143
- contextTypes?: ValidationMap<any> | undefined;
1053
+ (props: P): ReactElement<any, any> | null;
1144
1054
  /**
1145
- * Used to define default values for the props accepted by
1146
- * the component.
1147
- *
1148
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1149
- *
1150
- * @example
1151
- *
1152
- * ```tsx
1153
- * type Props = { name?: string }
1154
- *
1155
- * const MyComponent: FC<Props> = (props) => {
1156
- * return <div>{props.name}</div>
1157
- * }
1158
- *
1159
- * MyComponent.defaultProps = {
1160
- * name: 'John Doe'
1161
- * }
1162
- * ```
1163
- *
1164
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1055
+ * Ignored by React.
1056
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1165
1057
  */
1166
- defaultProps?: Partial<P> | undefined;
1058
+ propTypes?: any;
1167
1059
  /**
1168
1060
  * Used in debugging messages. You might want to set it
1169
1061
  * explicitly if you want to display a different name for
@@ -1185,38 +1077,6 @@ declare namespace React {
1185
1077
  displayName?: string | undefined;
1186
1078
  }
1187
1079
 
1188
- /**
1189
- * @deprecated - Equivalent to {@link React.FunctionComponent}.
1190
- *
1191
- * @see {@link React.FunctionComponent}
1192
- * @alias {@link VoidFunctionComponent}
1193
- */
1194
- type VFC<P = {}> = VoidFunctionComponent<P>;
1195
-
1196
- /**
1197
- * @deprecated - Equivalent to {@link React.FunctionComponent}.
1198
- *
1199
- * @see {@link React.FunctionComponent}
1200
- */
1201
- interface VoidFunctionComponent<P = {}> {
1202
- (
1203
- props: P,
1204
- /**
1205
- * @deprecated
1206
- *
1207
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1208
- */
1209
- deprecatedLegacyContext?: any,
1210
- ): ReactElement<any, any> | null;
1211
- propTypes?: WeakValidationMap<P> | undefined;
1212
- contextTypes?: ValidationMap<any> | undefined;
1213
- /**
1214
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1215
- */
1216
- defaultProps?: Partial<P> | undefined;
1217
- displayName?: string | undefined;
1218
- }
1219
-
1220
1080
  /**
1221
1081
  * The type of the ref received by a {@link ForwardRefRenderFunction}.
1222
1082
  *
@@ -1251,19 +1111,10 @@ declare namespace React {
1251
1111
  */
1252
1112
  displayName?: string | undefined;
1253
1113
  /**
1254
- * defaultProps are not supported on render functions passed to forwardRef.
1255
- *
1256
- * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
1257
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1258
- */
1259
- defaultProps?: never | undefined;
1260
- /**
1261
- * propTypes are not supported on render functions passed to forwardRef.
1262
- *
1263
- * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
1264
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1114
+ * Ignored by React.
1115
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1265
1116
  */
1266
- propTypes?: never | undefined;
1117
+ propTypes?: any;
1267
1118
  }
1268
1119
 
1269
1120
  /**
@@ -1273,48 +1124,21 @@ declare namespace React {
1273
1124
  * @template S The internal state of the component.
1274
1125
  */
1275
1126
  interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
1127
+ // constructor signature must match React.Component
1276
1128
  new(
1277
1129
  props: P,
1278
1130
  /**
1279
- * @deprecated
1280
- *
1281
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1131
+ * Value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
1132
+ * in `contextType`.
1282
1133
  */
1283
- deprecatedLegacyContext?: any,
1134
+ context?: any,
1284
1135
  ): Component<P, S>;
1285
1136
  /**
1286
- * Used to declare the types of the props accepted by the
1287
- * component. These types will be checked during rendering
1288
- * and in development only.
1289
- *
1290
- * We recommend using TypeScript instead of checking prop
1291
- * types at runtime.
1292
- *
1293
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1137
+ * Ignored by React.
1138
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1294
1139
  */
1295
- propTypes?: WeakValidationMap<P> | undefined;
1140
+ propTypes?: any;
1296
1141
  contextType?: Context<any> | undefined;
1297
- /**
1298
- * @deprecated use {@link ComponentClass.contextType} instead
1299
- *
1300
- * Lets you specify which legacy context is consumed by
1301
- * this component.
1302
- *
1303
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
1304
- */
1305
- contextTypes?: ValidationMap<any> | undefined;
1306
- /**
1307
- * @deprecated
1308
- *
1309
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
1310
- */
1311
- childContextTypes?: ValidationMap<any> | undefined;
1312
- /**
1313
- * Used to define default values for the props accepted by
1314
- * the component.
1315
- *
1316
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1317
- */
1318
1142
  defaultProps?: Partial<P> | undefined;
1319
1143
  /**
1320
1144
  * Used in debugging messages. You might want to set it
@@ -1333,7 +1157,7 @@ declare namespace React {
1333
1157
  * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
1334
1158
  */
1335
1159
  interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
1336
- new(props: P, deprecatedLegacyContext?: any): ClassicComponent<P, ComponentState>;
1160
+ new(props: P): ClassicComponent<P, ComponentState>;
1337
1161
  getDefaultProps?(): P;
1338
1162
  }
1339
1163
 
@@ -1348,7 +1172,7 @@ declare namespace React {
1348
1172
  */
1349
1173
  type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
1350
1174
  & C
1351
- & (new(props: P, deprecatedLegacyContext?: any) => T);
1175
+ & (new(props: P, context: any) => T);
1352
1176
 
1353
1177
  //
1354
1178
  // Component Specs and Lifecycle
@@ -1522,38 +1346,7 @@ declare namespace React {
1522
1346
  UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
1523
1347
  }
1524
1348
 
1525
- /**
1526
- * @deprecated
1527
- *
1528
- * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1529
- */
1530
- interface Mixin<P, S> extends ComponentLifecycle<P, S> {
1531
- mixins?: Array<Mixin<P, S>> | undefined;
1532
- statics?: {
1533
- [key: string]: any;
1534
- } | undefined;
1535
-
1536
- displayName?: string | undefined;
1537
- propTypes?: ValidationMap<any> | undefined;
1538
- contextTypes?: ValidationMap<any> | undefined;
1539
- childContextTypes?: ValidationMap<any> | undefined;
1540
-
1541
- getDefaultProps?(): P;
1542
- getInitialState?(): S;
1543
- }
1544
-
1545
- /**
1546
- * @deprecated
1547
- *
1548
- * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1549
- */
1550
- interface ComponentSpec<P, S> extends Mixin<P, S> {
1551
- render(): ReactNode;
1552
-
1553
- [propertyName: string]: any;
1554
- }
1555
-
1556
- function createRef<T>(): RefObject<T>;
1349
+ function createRef<T>(): RefObject<T | null>;
1557
1350
 
1558
1351
  /**
1559
1352
  * The type of the component returned from {@link forwardRef}.
@@ -1564,10 +1357,10 @@ declare namespace React {
1564
1357
  */
1565
1358
  interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
1566
1359
  /**
1567
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1360
+ * Ignored by React.
1361
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1568
1362
  */
1569
- defaultProps?: Partial<P> | undefined;
1570
- propTypes?: WeakValidationMap<P> | undefined;
1363
+ propTypes?: any;
1571
1364
  }
1572
1365
 
1573
1366
  /**
@@ -1598,29 +1391,24 @@ declare namespace React {
1598
1391
  * ```
1599
1392
  */
1600
1393
  function forwardRef<T, P = {}>(
1601
- render: ForwardRefRenderFunction<T, P>,
1394
+ render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
1602
1395
  ): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
1603
1396
 
1604
1397
  /**
1605
1398
  * Omits the 'ref' attribute from the given props object.
1606
1399
  *
1607
- * @template P The props object type.
1400
+ * @template Props The props object type.
1608
1401
  */
1609
- type PropsWithoutRef<P> =
1402
+ type PropsWithoutRef<Props> =
1610
1403
  // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
1611
1404
  // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
1612
1405
  // https://github.com/Microsoft/TypeScript/issues/28339
1613
- P extends any ? ("ref" extends keyof P ? Omit<P, "ref"> : P) : P;
1614
- /** Ensures that the props do not include string ref, which cannot be forwarded */
1615
- type PropsWithRef<P> =
1616
- // Note: String refs can be forwarded. We can't fix this bug without breaking a bunch of libraries now though.
1617
- // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
1618
- "ref" extends keyof P
1619
- ? P extends { ref?: infer R | undefined }
1620
- ? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
1621
- : P
1622
- : P
1623
- : P;
1406
+ Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
1407
+ /**
1408
+ * Ensures that the props do not include string ref, which cannot be forwarded
1409
+ * @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
1410
+ */
1411
+ type PropsWithRef<Props> = Props;
1624
1412
 
1625
1413
  type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
1626
1414
 
@@ -1652,7 +1440,7 @@ declare namespace React {
1652
1440
  * ```
1653
1441
  */
1654
1442
  type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
1655
- JSXElementConstructor<infer P> ? P
1443
+ JSXElementConstructor<infer Props> ? Props
1656
1444
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
1657
1445
  : {};
1658
1446
 
@@ -1679,9 +1467,11 @@ declare namespace React {
1679
1467
  * type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
1680
1468
  * ```
1681
1469
  */
1682
- type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
1683
- ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
1684
- : PropsWithRef<ComponentProps<T>>;
1470
+ type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
1471
+ // If it's a class i.e. newable we're dealing with a class component
1472
+ ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1473
+ : Props
1474
+ : ComponentProps<T>;
1685
1475
  /**
1686
1476
  * Used to retrieve the props a custom component accepts with its ref.
1687
1477
  *
@@ -1698,9 +1488,10 @@ declare namespace React {
1698
1488
  * type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
1699
1489
  * ```
1700
1490
  */
1701
- type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
1702
- ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
1703
- : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
1491
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
1492
+ // If it's a class i.e. newable we're dealing with a class component
1493
+ ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1494
+ : Props
1704
1495
  : never;
1705
1496
 
1706
1497
  /**
@@ -1728,10 +1519,24 @@ declare namespace React {
1728
1519
  */
1729
1520
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
1730
1521
 
1731
- type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
1732
- ComponentPropsWithoutRef<T> & RefAttributes<infer Method>
1733
- > ? Method
1734
- : ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1522
+ /**
1523
+ * Retrieves the type of the 'ref' prop for a given component type or tag name.
1524
+ *
1525
+ * @template C The component type.
1526
+ *
1527
+ * @example
1528
+ *
1529
+ * ```tsx
1530
+ * type MyComponentRef = React.ComponentRef<typeof MyComponent>;
1531
+ * ```
1532
+ *
1533
+ * @example
1534
+ *
1535
+ * ```tsx
1536
+ * type DivRef = React.ComponentRef<'div'>;
1537
+ * ```
1538
+ */
1539
+ type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1735
1540
  : never;
1736
1541
 
1737
1542
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
@@ -1832,6 +1637,11 @@ declare namespace React {
1832
1637
  * A {@link Dispatch} function can sometimes be called without any arguments.
1833
1638
  */
1834
1639
  type DispatchWithoutAction = () => void;
1640
+ // Limit the reducer to accept only 0 or 1 action arguments
1641
+ // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
1642
+ type AnyActionArg = [] | [any];
1643
+ // Get the dispatch type from the reducer arguments (captures optional action argument correctly)
1644
+ type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
1835
1645
  // Unlike redux, the actions _can_ be anything
1836
1646
  type Reducer<S, A> = (prevState: S, action: A) => S;
1837
1647
  // If useReducer accepts a reducer without action, dispatch may be called without any parameters.
@@ -1839,15 +1649,14 @@ declare namespace React {
1839
1649
  // types used to try and prevent the compiler from reducing S
1840
1650
  // to a supertype common with the second argument to useReducer()
1841
1651
  type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
1842
- type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
1843
- // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
1844
- type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
1845
- : never;
1846
1652
  type DependencyList = readonly unknown[];
1847
1653
 
1848
1654
  // NOTE: callbacks are _only_ allowed to return either void, or a destructor.
1849
1655
  type EffectCallback = () => void | Destructor;
1850
1656
 
1657
+ /**
1658
+ * @deprecated Use `RefObject` instead.
1659
+ */
1851
1660
  interface MutableRefObject<T> {
1852
1661
  current: T;
1853
1662
  }
@@ -1886,12 +1695,10 @@ declare namespace React {
1886
1695
  * @version 16.8.0
1887
1696
  * @see {@link https://react.dev/reference/react/useReducer}
1888
1697
  */
1889
- // overload where dispatch could accept 0 arguments.
1890
- function useReducer<R extends ReducerWithoutAction<any>, I>(
1891
- reducer: R,
1892
- initializerArg: I,
1893
- initializer: (arg: I) => ReducerStateWithoutAction<R>,
1894
- ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
1698
+ function useReducer<S, A extends AnyActionArg>(
1699
+ reducer: (prevState: S, ...args: A) => S,
1700
+ initialState: S,
1701
+ ): [S, ActionDispatch<A>];
1895
1702
  /**
1896
1703
  * An alternative to `useState`.
1897
1704
  *
@@ -1902,71 +1709,11 @@ declare namespace React {
1902
1709
  * @version 16.8.0
1903
1710
  * @see {@link https://react.dev/reference/react/useReducer}
1904
1711
  */
1905
- // overload where dispatch could accept 0 arguments.
1906
- function useReducer<R extends ReducerWithoutAction<any>>(
1907
- reducer: R,
1908
- initializerArg: ReducerStateWithoutAction<R>,
1909
- initializer?: undefined,
1910
- ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
1911
- /**
1912
- * An alternative to `useState`.
1913
- *
1914
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1915
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1916
- * updates because you can pass `dispatch` down instead of callbacks.
1917
- *
1918
- * @version 16.8.0
1919
- * @see {@link https://react.dev/reference/react/useReducer}
1920
- */
1921
- // overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
1922
- // If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
1923
- // the last overload effectively behaves as if the identity function (x => x) is the initializer.
1924
- function useReducer<R extends Reducer<any, any>, I>(
1925
- reducer: R,
1926
- initializerArg: I & ReducerState<R>,
1927
- initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
1928
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1929
- /**
1930
- * An alternative to `useState`.
1931
- *
1932
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1933
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1934
- * updates because you can pass `dispatch` down instead of callbacks.
1935
- *
1936
- * @version 16.8.0
1937
- * @see {@link https://react.dev/reference/react/useReducer}
1938
- */
1939
- // overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
1940
- function useReducer<R extends Reducer<any, any>, I>(
1941
- reducer: R,
1942
- initializerArg: I,
1943
- initializer: (arg: I) => ReducerState<R>,
1944
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1945
- /**
1946
- * An alternative to `useState`.
1947
- *
1948
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1949
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1950
- * updates because you can pass `dispatch` down instead of callbacks.
1951
- *
1952
- * @version 16.8.0
1953
- * @see {@link https://react.dev/reference/react/useReducer}
1954
- */
1955
-
1956
- // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.
1957
- // The Flow types do have an overload for 3-ary invocation with undefined initializer.
1958
-
1959
- // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common
1960
- // supertype between the reducer's return type and the initialState (or the initializer's return type),
1961
- // which would prevent autocompletion from ever working.
1962
-
1963
- // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
1964
- // in older versions, or a regression in newer versions of the typescript completion service.
1965
- function useReducer<R extends Reducer<any, any>>(
1966
- reducer: R,
1967
- initialState: ReducerState<R>,
1968
- initializer?: undefined,
1969
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1712
+ function useReducer<S, I, A extends AnyActionArg>(
1713
+ reducer: (prevState: S, ...args: A) => S,
1714
+ initialArg: I,
1715
+ init: (i: I) => S,
1716
+ ): [S, ActionDispatch<A>];
1970
1717
  /**
1971
1718
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1972
1719
  * (`initialValue`). The returned object will persist for the full lifetime of the component.
@@ -1977,7 +1724,7 @@ declare namespace React {
1977
1724
  * @version 16.8.0
1978
1725
  * @see {@link https://react.dev/reference/react/useRef}
1979
1726
  */
1980
- function useRef<T>(initialValue: T): MutableRefObject<T>;
1727
+ function useRef<T>(initialValue: T): RefObject<T>;
1981
1728
  // convenience overload for refs given as a ref prop as they typically start with a null value
1982
1729
  /**
1983
1730
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
@@ -1986,15 +1733,11 @@ declare namespace React {
1986
1733
  * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1987
1734
  * value around similar to how you’d use instance fields in classes.
1988
1735
  *
1989
- * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
1990
- * of the generic argument.
1991
- *
1992
1736
  * @version 16.8.0
1993
1737
  * @see {@link https://react.dev/reference/react/useRef}
1994
1738
  */
1995
- function useRef<T>(initialValue: T | null): RefObject<T>;
1996
- // convenience overload for potentially undefined initialValue / call with 0 arguments
1997
- // has a default to stop it from defaulting to {} instead
1739
+ function useRef<T>(initialValue: T | null): RefObject<T | null>;
1740
+ // convenience overload for undefined initialValue
1998
1741
  /**
1999
1742
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
2000
1743
  * (`initialValue`). The returned object will persist for the full lifetime of the component.
@@ -2005,7 +1748,7 @@ declare namespace React {
2005
1748
  * @version 16.8.0
2006
1749
  * @see {@link https://react.dev/reference/react/useRef}
2007
1750
  */
2008
- function useRef<T = undefined>(): MutableRefObject<T | undefined>;
1751
+ function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
2009
1752
  /**
2010
1753
  * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
2011
1754
  * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
@@ -2030,13 +1773,17 @@ declare namespace React {
2030
1773
  * @see {@link https://react.dev/reference/react/useEffect}
2031
1774
  */
2032
1775
  function useEffect(effect: EffectCallback, deps?: DependencyList): void;
1776
+ /**
1777
+ * @see {@link https://react.dev/reference/react/useEffectEvent `useEffectEvent()` documentation}
1778
+ * @version 19.2.0
1779
+ */
1780
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1781
+ export function useEffectEvent<T extends Function>(callback: T): T;
2033
1782
  // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref<T>
2034
1783
  /**
2035
1784
  * `useImperativeHandle` customizes the instance value that is exposed to parent components when using
2036
1785
  * `ref`. As always, imperative code using refs should be avoided in most cases.
2037
1786
  *
2038
- * `useImperativeHandle` should be used with `React.forwardRef`.
2039
- *
2040
1787
  * @version 16.8.0
2041
1788
  * @see {@link https://react.dev/reference/react/useImperativeHandle}
2042
1789
  */
@@ -2052,7 +1799,7 @@ declare namespace React {
2052
1799
  */
2053
1800
  // A specific function type would not trigger implicit any.
2054
1801
  // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
2055
- // eslint-disable-next-line @typescript-eslint/ban-types
1802
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
2056
1803
  function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
2057
1804
  /**
2058
1805
  * `useMemo` will only recompute the memoized value when one of the `deps` has changed.
@@ -2075,8 +1822,7 @@ declare namespace React {
2075
1822
  // it's just the function name without the "use" prefix.
2076
1823
  function useDebugValue<T>(value: T, format?: (value: T) => any): void;
2077
1824
 
2078
- // must be synchronous
2079
- export type TransitionFunction = () => VoidOrUndefinedOnly;
1825
+ export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
2080
1826
  // strange definition to allow vscode to show documentation on the invocation
2081
1827
  export interface TransitionStartFunction {
2082
1828
  /**
@@ -2084,7 +1830,7 @@ declare namespace React {
2084
1830
  *
2085
1831
  * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
2086
1832
  *
2087
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
1833
+ * @param callback A function which causes state updates that can be deferred.
2088
1834
  */
2089
1835
  (callback: TransitionFunction): void;
2090
1836
  }
@@ -2098,10 +1844,11 @@ declare namespace React {
2098
1844
  * A good example of this is a text input.
2099
1845
  *
2100
1846
  * @param value The value that is going to be deferred
1847
+ * @param initialValue A value to use during the initial render of a component. If this option is omitted, `useDeferredValue` will not defer during the initial render, because there’s no previous version of `value` that it can render instead.
2101
1848
  *
2102
1849
  * @see {@link https://react.dev/reference/react/useDeferredValue}
2103
1850
  */
2104
- export function useDeferredValue<T>(value: T): T;
1851
+ export function useDeferredValue<T>(value: T, initialValue?: T): T;
2105
1852
 
2106
1853
  /**
2107
1854
  * Allows components to avoid undesirable loading states by waiting for content to load
@@ -2123,7 +1870,7 @@ declare namespace React {
2123
1870
  /**
2124
1871
  * Similar to `useTransition` but allows uses where hooks are not available.
2125
1872
  *
2126
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
1873
+ * @param callback A function which causes state updates that can be deferred.
2127
1874
  */
2128
1875
  export function startTransition(scope: TransitionFunction): void;
2129
1876
 
@@ -2138,6 +1885,11 @@ declare namespace React {
2138
1885
  *
2139
1886
  * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
2140
1887
  */
1888
+ // NOTES
1889
+ // - the order of these signatures matters - typescript will check the signatures in source order.
1890
+ // If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
1891
+ // `strictNullChecks: false`.
1892
+ // - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
2141
1893
  // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
2142
1894
  export function act(callback: () => VoidOrUndefinedOnly): void;
2143
1895
  export function act<T>(callback: () => T | Promise<T>): Promise<T>;
@@ -2165,6 +1917,92 @@ declare namespace React {
2165
1917
  getServerSnapshot?: () => Snapshot,
2166
1918
  ): Snapshot;
2167
1919
 
1920
+ export function useOptimistic<State>(
1921
+ passthrough: State,
1922
+ ): [State, (action: State | ((pendingState: State) => State)) => void];
1923
+ export function useOptimistic<State, Action>(
1924
+ passthrough: State,
1925
+ reducer: (state: State, action: Action) => State,
1926
+ ): [State, (action: Action) => void];
1927
+
1928
+ interface UntrackedReactPromise<T> extends PromiseLike<T> {
1929
+ status?: void;
1930
+ }
1931
+
1932
+ export interface PendingReactPromise<T> extends PromiseLike<T> {
1933
+ status: "pending";
1934
+ }
1935
+
1936
+ export interface FulfilledReactPromise<T> extends PromiseLike<T> {
1937
+ status: "fulfilled";
1938
+ value: T;
1939
+ }
1940
+
1941
+ export interface RejectedReactPromise<T> extends PromiseLike<T> {
1942
+ status: "rejected";
1943
+ reason: unknown;
1944
+ }
1945
+
1946
+ export type ReactPromise<T> =
1947
+ | UntrackedReactPromise<T>
1948
+ | PendingReactPromise<T>
1949
+ | FulfilledReactPromise<T>
1950
+ | RejectedReactPromise<T>;
1951
+
1952
+ export type Usable<T> = ReactPromise<T> | Context<T>;
1953
+
1954
+ export function use<T>(usable: Usable<T>): T;
1955
+
1956
+ export function useActionState<State>(
1957
+ action: (state: Awaited<State>) => State | Promise<State>,
1958
+ initialState: Awaited<State>,
1959
+ permalink?: string,
1960
+ ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
1961
+ export function useActionState<State, Payload>(
1962
+ action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
1963
+ initialState: Awaited<State>,
1964
+ permalink?: string,
1965
+ ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1966
+
1967
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1968
+ export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
1969
+
1970
+ export interface CacheSignal {}
1971
+ /**
1972
+ * @version 19.2.0
1973
+ */
1974
+ export function cacheSignal(): null | CacheSignal;
1975
+
1976
+ export interface ActivityProps {
1977
+ /**
1978
+ * @default "visible"
1979
+ */
1980
+ mode?:
1981
+ | "hidden"
1982
+ | "visible"
1983
+ | undefined;
1984
+ /**
1985
+ * A name for this Activity boundary for instrumentation purposes.
1986
+ * The name will help identify this boundary in React DevTools.
1987
+ */
1988
+ name?: string | undefined;
1989
+ children: ReactNode;
1990
+ }
1991
+
1992
+ /**
1993
+ * @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation}
1994
+ * @version 19.2.0
1995
+ */
1996
+ export const Activity: ExoticComponent<ActivityProps>;
1997
+
1998
+ /**
1999
+ * Warning: Only available in development builds.
2000
+ *
2001
+ * @see {@link https://react.dev/reference/react/captureOwnerStack Reference docs}
2002
+ * @version 19.1.0
2003
+ */
2004
+ function captureOwnerStack(): string | null;
2005
+
2168
2006
  //
2169
2007
  // Event System
2170
2008
  // ----------------------------------------------------------------------
@@ -2237,6 +2075,10 @@ declare namespace React {
2237
2075
  target: EventTarget & T;
2238
2076
  }
2239
2077
 
2078
+ interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
2079
+ data: string;
2080
+ }
2081
+
2240
2082
  export type ModifierKey =
2241
2083
  | "Alt"
2242
2084
  | "AltGraph"
@@ -2332,6 +2174,11 @@ declare namespace React {
2332
2174
  pseudoElement: string;
2333
2175
  }
2334
2176
 
2177
+ interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
2178
+ oldState: "closed" | "open";
2179
+ newState: "closed" | "open";
2180
+ }
2181
+
2335
2182
  interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
2336
2183
  elapsedTime: number;
2337
2184
  propertyName: string;
@@ -2352,6 +2199,7 @@ declare namespace React {
2352
2199
  type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
2353
2200
  type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
2354
2201
  type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
2202
+ type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
2355
2203
  type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
2356
2204
  type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
2357
2205
  type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
@@ -2359,6 +2207,7 @@ declare namespace React {
2359
2207
  type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
2360
2208
  type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
2361
2209
  type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
2210
+ type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
2362
2211
  type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
2363
2212
 
2364
2213
  //
@@ -2409,7 +2258,7 @@ declare namespace React {
2409
2258
  // Form Events
2410
2259
  onChange?: FormEventHandler<T> | undefined;
2411
2260
  onChangeCapture?: FormEventHandler<T> | undefined;
2412
- onBeforeInput?: FormEventHandler<T> | undefined;
2261
+ onBeforeInput?: InputEventHandler<T> | undefined;
2413
2262
  onBeforeInputCapture?: FormEventHandler<T> | undefined;
2414
2263
  onInput?: FormEventHandler<T> | undefined;
2415
2264
  onInputCapture?: FormEventHandler<T> | undefined;
@@ -2429,9 +2278,9 @@ declare namespace React {
2429
2278
  // Keyboard Events
2430
2279
  onKeyDown?: KeyboardEventHandler<T> | undefined;
2431
2280
  onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
2432
- /** @deprecated */
2281
+ /** @deprecated Use `onKeyUp` or `onKeyDown` instead */
2433
2282
  onKeyPress?: KeyboardEventHandler<T> | undefined;
2434
- /** @deprecated */
2283
+ /** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
2435
2284
  onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
2436
2285
  onKeyUp?: KeyboardEventHandler<T> | undefined;
2437
2286
  onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
@@ -2467,8 +2316,6 @@ declare namespace React {
2467
2316
  onProgressCapture?: ReactEventHandler<T> | undefined;
2468
2317
  onRateChange?: ReactEventHandler<T> | undefined;
2469
2318
  onRateChangeCapture?: ReactEventHandler<T> | undefined;
2470
- onResize?: ReactEventHandler<T> | undefined;
2471
- onResizeCapture?: ReactEventHandler<T> | undefined;
2472
2319
  onSeeked?: ReactEventHandler<T> | undefined;
2473
2320
  onSeekedCapture?: ReactEventHandler<T> | undefined;
2474
2321
  onSeeking?: ReactEventHandler<T> | undefined;
@@ -2559,6 +2406,8 @@ declare namespace React {
2559
2406
  // UI Events
2560
2407
  onScroll?: UIEventHandler<T> | undefined;
2561
2408
  onScrollCapture?: UIEventHandler<T> | undefined;
2409
+ onScrollEnd?: UIEventHandler<T> | undefined;
2410
+ onScrollEndCapture?: UIEventHandler<T> | undefined;
2562
2411
 
2563
2412
  // Wheel Events
2564
2413
  onWheel?: WheelEventHandler<T> | undefined;
@@ -2572,9 +2421,19 @@ declare namespace React {
2572
2421
  onAnimationIteration?: AnimationEventHandler<T> | undefined;
2573
2422
  onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
2574
2423
 
2424
+ // Toggle Events
2425
+ onToggle?: ToggleEventHandler<T> | undefined;
2426
+ onBeforeToggle?: ToggleEventHandler<T> | undefined;
2427
+
2575
2428
  // Transition Events
2429
+ onTransitionCancel?: TransitionEventHandler<T> | undefined;
2430
+ onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
2576
2431
  onTransitionEnd?: TransitionEventHandler<T> | undefined;
2577
2432
  onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
2433
+ onTransitionRun?: TransitionEventHandler<T> | undefined;
2434
+ onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
2435
+ onTransitionStart?: TransitionEventHandler<T> | undefined;
2436
+ onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
2578
2437
  }
2579
2438
 
2580
2439
  export interface CSSProperties extends CSS.Properties<string | number> {
@@ -2894,12 +2753,14 @@ declare namespace React {
2894
2753
 
2895
2754
  // Standard HTML Attributes
2896
2755
  accessKey?: string | undefined;
2756
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
2897
2757
  autoFocus?: boolean | undefined;
2898
2758
  className?: string | undefined;
2899
2759
  contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
2900
2760
  contextMenu?: string | undefined;
2901
2761
  dir?: string | undefined;
2902
2762
  draggable?: Booleanish | undefined;
2763
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
2903
2764
  hidden?: boolean | undefined;
2904
2765
  id?: string | undefined;
2905
2766
  lang?: string | undefined;
@@ -2931,7 +2792,6 @@ declare namespace React {
2931
2792
  vocab?: string | undefined;
2932
2793
 
2933
2794
  // Non-standard Attributes
2934
- autoCapitalize?: string | undefined;
2935
2795
  autoCorrect?: string | undefined;
2936
2796
  autoSave?: string | undefined;
2937
2797
  color?: string | undefined;
@@ -2944,7 +2804,16 @@ declare namespace React {
2944
2804
  security?: string | undefined;
2945
2805
  unselectable?: "on" | "off" | undefined;
2946
2806
 
2807
+ // Popover API
2808
+ popover?: "" | "auto" | "manual" | "hint" | undefined;
2809
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
2810
+ popoverTarget?: string | undefined;
2811
+
2947
2812
  // Living Standard
2813
+ /**
2814
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
2815
+ */
2816
+ inert?: boolean | undefined;
2948
2817
  /**
2949
2818
  * Hints at the type of data that might be entered by the user while editing the element or its contents
2950
2819
  * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
@@ -2955,6 +2824,14 @@ declare namespace React {
2955
2824
  * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
2956
2825
  */
2957
2826
  is?: string | undefined;
2827
+ /**
2828
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2829
+ */
2830
+ exportparts?: string | undefined;
2831
+ /**
2832
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2833
+ */
2834
+ part?: string | undefined;
2958
2835
  }
2959
2836
 
2960
2837
  /**
@@ -2971,6 +2848,7 @@ declare namespace React {
2971
2848
  action?:
2972
2849
  | string
2973
2850
  | undefined
2851
+ | ((formData: FormData) => void | Promise<void>)
2974
2852
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2975
2853
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2976
2854
  ];
@@ -3005,6 +2883,7 @@ declare namespace React {
3005
2883
  formAction?:
3006
2884
  | string
3007
2885
  | undefined
2886
+ | ((formData: FormData) => void | Promise<void>)
3008
2887
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3009
2888
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3010
2889
  ];
@@ -3137,6 +3016,7 @@ declare namespace React {
3137
3016
  form?: string | undefined;
3138
3017
  formAction?:
3139
3018
  | string
3019
+ | ((formData: FormData) => void | Promise<void>)
3140
3020
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3141
3021
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3142
3022
  ]
@@ -3170,7 +3050,6 @@ declare namespace React {
3170
3050
 
3171
3051
  interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
3172
3052
  open?: boolean | undefined;
3173
- onToggle?: ReactEventHandler<T> | undefined;
3174
3053
  name?: string | undefined;
3175
3054
  }
3176
3055
 
@@ -3180,6 +3059,7 @@ declare namespace React {
3180
3059
  }
3181
3060
 
3182
3061
  interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
3062
+ closedby?: "any" | "closerequest" | "none" | undefined;
3183
3063
  onCancel?: ReactEventHandler<T> | undefined;
3184
3064
  onClose?: ReactEventHandler<T> | undefined;
3185
3065
  open?: boolean | undefined;
@@ -3203,6 +3083,7 @@ declare namespace React {
3203
3083
  action?:
3204
3084
  | string
3205
3085
  | undefined
3086
+ | ((formData: FormData) => void | Promise<void>)
3206
3087
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3207
3088
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3208
3089
  ];
@@ -3241,6 +3122,8 @@ declare namespace React {
3241
3122
  width?: number | string | undefined;
3242
3123
  }
3243
3124
 
3125
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {}
3126
+
3244
3127
  interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
3245
3128
  alt?: string | undefined;
3246
3129
  crossOrigin?: CrossOrigin;
@@ -3250,7 +3133,12 @@ declare namespace React {
3250
3133
  loading?: "eager" | "lazy" | undefined;
3251
3134
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3252
3135
  sizes?: string | undefined;
3253
- src?: string | undefined;
3136
+ src?:
3137
+ | string
3138
+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES[
3139
+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES
3140
+ ]
3141
+ | undefined;
3254
3142
  srcSet?: string | undefined;
3255
3143
  useMap?: string | undefined;
3256
3144
  width?: number | string | undefined;
@@ -3355,10 +3243,10 @@ declare namespace React {
3355
3243
  capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3356
3244
  checked?: boolean | undefined;
3357
3245
  disabled?: boolean | undefined;
3358
- enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
3359
3246
  form?: string | undefined;
3360
3247
  formAction?:
3361
3248
  | string
3249
+ | ((formData: FormData) => void | Promise<void>)
3362
3250
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3363
3251
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3364
3252
  ]
@@ -3409,6 +3297,7 @@ declare namespace React {
3409
3297
 
3410
3298
  interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
3411
3299
  as?: string | undefined;
3300
+ blocking?: "render" | (string & {}) | undefined;
3412
3301
  crossOrigin?: CrossOrigin;
3413
3302
  fetchPriority?: "high" | "low" | "auto";
3414
3303
  href?: string | undefined;
@@ -3421,6 +3310,9 @@ declare namespace React {
3421
3310
  sizes?: string | undefined;
3422
3311
  type?: string | undefined;
3423
3312
  charSet?: string | undefined;
3313
+
3314
+ // React props
3315
+ precedence?: string | undefined;
3424
3316
  }
3425
3317
 
3426
3318
  interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3431,6 +3323,8 @@ declare namespace React {
3431
3323
  type?: string | undefined;
3432
3324
  }
3433
3325
 
3326
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {}
3327
+
3434
3328
  interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
3435
3329
  autoPlay?: boolean | undefined;
3436
3330
  controls?: boolean | undefined;
@@ -3441,7 +3335,12 @@ declare namespace React {
3441
3335
  muted?: boolean | undefined;
3442
3336
  playsInline?: boolean | undefined;
3443
3337
  preload?: string | undefined;
3444
- src?: string | undefined;
3338
+ src?:
3339
+ | string
3340
+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES[
3341
+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES
3342
+ ]
3343
+ | undefined;
3445
3344
  }
3446
3345
 
3447
3346
  interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3518,10 +3417,12 @@ declare namespace React {
3518
3417
 
3519
3418
  interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
3520
3419
  async?: boolean | undefined;
3420
+ blocking?: "render" | (string & {}) | undefined;
3521
3421
  /** @deprecated */
3522
3422
  charSet?: string | undefined;
3523
3423
  crossOrigin?: CrossOrigin;
3524
3424
  defer?: boolean | undefined;
3425
+ fetchPriority?: "high" | "low" | "auto" | undefined;
3525
3426
  integrity?: string | undefined;
3526
3427
  noModule?: boolean | undefined;
3527
3428
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
@@ -3552,9 +3453,14 @@ declare namespace React {
3552
3453
  }
3553
3454
 
3554
3455
  interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
3456
+ blocking?: "render" | (string & {}) | undefined;
3555
3457
  media?: string | undefined;
3556
3458
  scoped?: boolean | undefined;
3557
3459
  type?: string | undefined;
3460
+
3461
+ // React props
3462
+ href?: string | undefined;
3463
+ precedence?: string | undefined;
3558
3464
  }
3559
3465
 
3560
3466
  interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3628,6 +3534,9 @@ declare namespace React {
3628
3534
  width?: number | string | undefined;
3629
3535
  disablePictureInPicture?: boolean | undefined;
3630
3536
  disableRemotePlayback?: boolean | undefined;
3537
+
3538
+ onResize?: ReactEventHandler<T> | undefined;
3539
+ onResizeCapture?: ReactEventHandler<T> | undefined;
3631
3540
  }
3632
3541
 
3633
3542
  // this list is "complete" in that it contains every SVG attribute
@@ -3721,7 +3630,21 @@ declare namespace React {
3721
3630
  direction?: number | string | undefined;
3722
3631
  display?: number | string | undefined;
3723
3632
  divisor?: number | string | undefined;
3724
- dominantBaseline?: number | string | undefined;
3633
+ dominantBaseline?:
3634
+ | "auto"
3635
+ | "use-script"
3636
+ | "no-change"
3637
+ | "reset-size"
3638
+ | "ideographic"
3639
+ | "alphabetic"
3640
+ | "hanging"
3641
+ | "mathematical"
3642
+ | "central"
3643
+ | "middle"
3644
+ | "text-after-edge"
3645
+ | "text-before-edge"
3646
+ | "inherit"
3647
+ | undefined;
3725
3648
  dur?: number | string | undefined;
3726
3649
  dx?: number | string | undefined;
3727
3650
  dy?: number | string | undefined;
@@ -3868,7 +3791,7 @@ declare namespace React {
3868
3791
  tableValues?: number | string | undefined;
3869
3792
  targetX?: number | string | undefined;
3870
3793
  targetY?: number | string | undefined;
3871
- textAnchor?: string | undefined;
3794
+ textAnchor?: "start" | "middle" | "end" | "inherit" | undefined;
3872
3795
  textDecoration?: number | string | undefined;
3873
3796
  textLength?: number | string | undefined;
3874
3797
  textRendering?: number | string | undefined;
@@ -3942,259 +3865,184 @@ declare namespace React {
3942
3865
  webpreferences?: string | undefined;
3943
3866
  }
3944
3867
 
3945
- //
3946
- // React.DOM
3947
- // ----------------------------------------------------------------------
3948
-
3949
- interface ReactHTML {
3950
- a: DetailedHTMLFactory<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
3951
- abbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3952
- address: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3953
- area: DetailedHTMLFactory<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
3954
- article: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3955
- aside: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3956
- audio: DetailedHTMLFactory<AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
3957
- b: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3958
- base: DetailedHTMLFactory<BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
3959
- bdi: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3960
- bdo: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3961
- big: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3962
- blockquote: DetailedHTMLFactory<BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
3963
- body: DetailedHTMLFactory<HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
3964
- br: DetailedHTMLFactory<HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
3965
- button: DetailedHTMLFactory<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
3966
- canvas: DetailedHTMLFactory<CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
3967
- caption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3968
- center: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3969
- cite: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3970
- code: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3971
- col: DetailedHTMLFactory<ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3972
- colgroup: DetailedHTMLFactory<ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3973
- data: DetailedHTMLFactory<DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
3974
- datalist: DetailedHTMLFactory<HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
3975
- dd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3976
- del: DetailedHTMLFactory<DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
3977
- details: DetailedHTMLFactory<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
3978
- dfn: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3979
- dialog: DetailedHTMLFactory<DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
3980
- div: DetailedHTMLFactory<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
3981
- dl: DetailedHTMLFactory<HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
3982
- dt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3983
- em: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3984
- embed: DetailedHTMLFactory<EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
3985
- fieldset: DetailedHTMLFactory<FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
3986
- figcaption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3987
- figure: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3988
- footer: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3989
- form: DetailedHTMLFactory<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
3990
- h1: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3991
- h2: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3992
- h3: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3993
- h4: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3994
- h5: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3995
- h6: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3996
- head: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLHeadElement>;
3997
- header: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3998
- hgroup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3999
- hr: DetailedHTMLFactory<HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
4000
- html: DetailedHTMLFactory<HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
4001
- i: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4002
- iframe: DetailedHTMLFactory<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
4003
- img: DetailedHTMLFactory<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
4004
- input: DetailedHTMLFactory<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4005
- ins: DetailedHTMLFactory<InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
4006
- kbd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4007
- keygen: DetailedHTMLFactory<KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
4008
- label: DetailedHTMLFactory<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
4009
- legend: DetailedHTMLFactory<HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
4010
- li: DetailedHTMLFactory<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
4011
- link: DetailedHTMLFactory<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
4012
- main: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4013
- map: DetailedHTMLFactory<MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
4014
- mark: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4015
- menu: DetailedHTMLFactory<MenuHTMLAttributes<HTMLElement>, HTMLElement>;
4016
- menuitem: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4017
- meta: DetailedHTMLFactory<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
4018
- meter: DetailedHTMLFactory<MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
4019
- nav: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4020
- noscript: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4021
- object: DetailedHTMLFactory<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
4022
- ol: DetailedHTMLFactory<OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
4023
- optgroup: DetailedHTMLFactory<OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
4024
- option: DetailedHTMLFactory<OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
4025
- output: DetailedHTMLFactory<OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
4026
- p: DetailedHTMLFactory<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
4027
- param: DetailedHTMLFactory<ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
4028
- picture: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4029
- pre: DetailedHTMLFactory<HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
4030
- progress: DetailedHTMLFactory<ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
4031
- q: DetailedHTMLFactory<QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4032
- rp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4033
- rt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4034
- ruby: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4035
- s: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4036
- samp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4037
- search: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4038
- slot: DetailedHTMLFactory<SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
4039
- script: DetailedHTMLFactory<ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
4040
- section: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4041
- select: DetailedHTMLFactory<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
4042
- small: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4043
- source: DetailedHTMLFactory<SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
4044
- span: DetailedHTMLFactory<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
4045
- strong: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4046
- style: DetailedHTMLFactory<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
4047
- sub: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4048
- summary: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4049
- sup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4050
- table: DetailedHTMLFactory<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
4051
- template: DetailedHTMLFactory<HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
4052
- tbody: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4053
- td: DetailedHTMLFactory<TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
4054
- textarea: DetailedHTMLFactory<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
4055
- tfoot: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4056
- th: DetailedHTMLFactory<ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
4057
- thead: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4058
- time: DetailedHTMLFactory<TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
4059
- title: DetailedHTMLFactory<HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
4060
- tr: DetailedHTMLFactory<HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
4061
- track: DetailedHTMLFactory<TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
4062
- u: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4063
- ul: DetailedHTMLFactory<HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
4064
- "var": DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4065
- video: DetailedHTMLFactory<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
4066
- wbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4067
- webview: DetailedHTMLFactory<WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
4068
- }
4069
-
4070
- interface ReactSVG {
4071
- animate: SVGFactory;
4072
- circle: SVGFactory;
4073
- clipPath: SVGFactory;
4074
- defs: SVGFactory;
4075
- desc: SVGFactory;
4076
- ellipse: SVGFactory;
4077
- feBlend: SVGFactory;
4078
- feColorMatrix: SVGFactory;
4079
- feComponentTransfer: SVGFactory;
4080
- feComposite: SVGFactory;
4081
- feConvolveMatrix: SVGFactory;
4082
- feDiffuseLighting: SVGFactory;
4083
- feDisplacementMap: SVGFactory;
4084
- feDistantLight: SVGFactory;
4085
- feDropShadow: SVGFactory;
4086
- feFlood: SVGFactory;
4087
- feFuncA: SVGFactory;
4088
- feFuncB: SVGFactory;
4089
- feFuncG: SVGFactory;
4090
- feFuncR: SVGFactory;
4091
- feGaussianBlur: SVGFactory;
4092
- feImage: SVGFactory;
4093
- feMerge: SVGFactory;
4094
- feMergeNode: SVGFactory;
4095
- feMorphology: SVGFactory;
4096
- feOffset: SVGFactory;
4097
- fePointLight: SVGFactory;
4098
- feSpecularLighting: SVGFactory;
4099
- feSpotLight: SVGFactory;
4100
- feTile: SVGFactory;
4101
- feTurbulence: SVGFactory;
4102
- filter: SVGFactory;
4103
- foreignObject: SVGFactory;
4104
- g: SVGFactory;
4105
- image: SVGFactory;
4106
- line: SVGFactory;
4107
- linearGradient: SVGFactory;
4108
- marker: SVGFactory;
4109
- mask: SVGFactory;
4110
- metadata: SVGFactory;
4111
- path: SVGFactory;
4112
- pattern: SVGFactory;
4113
- polygon: SVGFactory;
4114
- polyline: SVGFactory;
4115
- radialGradient: SVGFactory;
4116
- rect: SVGFactory;
4117
- stop: SVGFactory;
4118
- svg: SVGFactory;
4119
- switch: SVGFactory;
4120
- symbol: SVGFactory;
4121
- text: SVGFactory;
4122
- textPath: SVGFactory;
4123
- tspan: SVGFactory;
4124
- use: SVGFactory;
4125
- view: SVGFactory;
4126
- }
4127
-
4128
- interface ReactDOM extends ReactHTML, ReactSVG {}
4129
-
4130
- //
4131
- // React.PropTypes
4132
- // ----------------------------------------------------------------------
4133
-
4134
- /**
4135
- * @deprecated Use `Validator` from the ´prop-types` instead.
4136
- */
4137
- type Validator<T> = PropTypes.Validator<T>;
4138
-
4139
- /**
4140
- * @deprecated Use `Requireable` from the ´prop-types` instead.
4141
- */
4142
- type Requireable<T> = PropTypes.Requireable<T>;
4143
-
4144
- /**
4145
- * @deprecated Use `ValidationMap` from the ´prop-types` instead.
4146
- */
4147
- type ValidationMap<T> = PropTypes.ValidationMap<T>;
4148
-
4149
- /**
4150
- * @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
4151
- */
4152
- type WeakValidationMap<T> = {
4153
- [K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
4154
- : undefined extends T[K] ? Validator<T[K] | null | undefined>
4155
- : Validator<T[K]>;
4156
- };
4157
-
4158
- /**
4159
- * @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
4160
- */
4161
- interface ReactPropTypes {
4162
- any: typeof PropTypes.any;
4163
- array: typeof PropTypes.array;
4164
- bool: typeof PropTypes.bool;
4165
- func: typeof PropTypes.func;
4166
- number: typeof PropTypes.number;
4167
- object: typeof PropTypes.object;
4168
- string: typeof PropTypes.string;
4169
- node: typeof PropTypes.node;
4170
- element: typeof PropTypes.element;
4171
- instanceOf: typeof PropTypes.instanceOf;
4172
- oneOf: typeof PropTypes.oneOf;
4173
- oneOfType: typeof PropTypes.oneOfType;
4174
- arrayOf: typeof PropTypes.arrayOf;
4175
- objectOf: typeof PropTypes.objectOf;
4176
- shape: typeof PropTypes.shape;
4177
- exact: typeof PropTypes.exact;
4178
- }
4179
-
4180
- //
4181
- // React.Children
4182
- // ----------------------------------------------------------------------
4183
-
4184
- /**
4185
- * @deprecated - Use `typeof React.Children` instead.
4186
- */
4187
- // Sync with type of `const Children`.
4188
- interface ReactChildren {
4189
- map<T, C>(
4190
- children: C | readonly C[],
4191
- fn: (child: C, index: number) => T,
4192
- ): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
4193
- forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
4194
- count(children: any): number;
4195
- only<C>(children: C): C extends any[] ? never : C;
4196
- toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
4197
- }
3868
+ // TODO: Move to react-dom
3869
+ type HTMLElementType =
3870
+ | "a"
3871
+ | "abbr"
3872
+ | "address"
3873
+ | "area"
3874
+ | "article"
3875
+ | "aside"
3876
+ | "audio"
3877
+ | "b"
3878
+ | "base"
3879
+ | "bdi"
3880
+ | "bdo"
3881
+ | "big"
3882
+ | "blockquote"
3883
+ | "body"
3884
+ | "br"
3885
+ | "button"
3886
+ | "canvas"
3887
+ | "caption"
3888
+ | "center"
3889
+ | "cite"
3890
+ | "code"
3891
+ | "col"
3892
+ | "colgroup"
3893
+ | "data"
3894
+ | "datalist"
3895
+ | "dd"
3896
+ | "del"
3897
+ | "details"
3898
+ | "dfn"
3899
+ | "dialog"
3900
+ | "div"
3901
+ | "dl"
3902
+ | "dt"
3903
+ | "em"
3904
+ | "embed"
3905
+ | "fieldset"
3906
+ | "figcaption"
3907
+ | "figure"
3908
+ | "footer"
3909
+ | "form"
3910
+ | "h1"
3911
+ | "h2"
3912
+ | "h3"
3913
+ | "h4"
3914
+ | "h5"
3915
+ | "h6"
3916
+ | "head"
3917
+ | "header"
3918
+ | "hgroup"
3919
+ | "hr"
3920
+ | "html"
3921
+ | "i"
3922
+ | "iframe"
3923
+ | "img"
3924
+ | "input"
3925
+ | "ins"
3926
+ | "kbd"
3927
+ | "keygen"
3928
+ | "label"
3929
+ | "legend"
3930
+ | "li"
3931
+ | "link"
3932
+ | "main"
3933
+ | "map"
3934
+ | "mark"
3935
+ | "menu"
3936
+ | "menuitem"
3937
+ | "meta"
3938
+ | "meter"
3939
+ | "nav"
3940
+ | "noscript"
3941
+ | "object"
3942
+ | "ol"
3943
+ | "optgroup"
3944
+ | "option"
3945
+ | "output"
3946
+ | "p"
3947
+ | "param"
3948
+ | "picture"
3949
+ | "pre"
3950
+ | "progress"
3951
+ | "q"
3952
+ | "rp"
3953
+ | "rt"
3954
+ | "ruby"
3955
+ | "s"
3956
+ | "samp"
3957
+ | "search"
3958
+ | "slot"
3959
+ | "script"
3960
+ | "section"
3961
+ | "select"
3962
+ | "small"
3963
+ | "source"
3964
+ | "span"
3965
+ | "strong"
3966
+ | "style"
3967
+ | "sub"
3968
+ | "summary"
3969
+ | "sup"
3970
+ | "table"
3971
+ | "template"
3972
+ | "tbody"
3973
+ | "td"
3974
+ | "textarea"
3975
+ | "tfoot"
3976
+ | "th"
3977
+ | "thead"
3978
+ | "time"
3979
+ | "title"
3980
+ | "tr"
3981
+ | "track"
3982
+ | "u"
3983
+ | "ul"
3984
+ | "var"
3985
+ | "video"
3986
+ | "wbr"
3987
+ | "webview";
3988
+
3989
+ // TODO: Move to react-dom
3990
+ type SVGElementType =
3991
+ | "animate"
3992
+ | "circle"
3993
+ | "clipPath"
3994
+ | "defs"
3995
+ | "desc"
3996
+ | "ellipse"
3997
+ | "feBlend"
3998
+ | "feColorMatrix"
3999
+ | "feComponentTransfer"
4000
+ | "feComposite"
4001
+ | "feConvolveMatrix"
4002
+ | "feDiffuseLighting"
4003
+ | "feDisplacementMap"
4004
+ | "feDistantLight"
4005
+ | "feDropShadow"
4006
+ | "feFlood"
4007
+ | "feFuncA"
4008
+ | "feFuncB"
4009
+ | "feFuncG"
4010
+ | "feFuncR"
4011
+ | "feGaussianBlur"
4012
+ | "feImage"
4013
+ | "feMerge"
4014
+ | "feMergeNode"
4015
+ | "feMorphology"
4016
+ | "feOffset"
4017
+ | "fePointLight"
4018
+ | "feSpecularLighting"
4019
+ | "feSpotLight"
4020
+ | "feTile"
4021
+ | "feTurbulence"
4022
+ | "filter"
4023
+ | "foreignObject"
4024
+ | "g"
4025
+ | "image"
4026
+ | "line"
4027
+ | "linearGradient"
4028
+ | "marker"
4029
+ | "mask"
4030
+ | "metadata"
4031
+ | "path"
4032
+ | "pattern"
4033
+ | "polygon"
4034
+ | "polyline"
4035
+ | "radialGradient"
4036
+ | "rect"
4037
+ | "stop"
4038
+ | "svg"
4039
+ | "switch"
4040
+ | "symbol"
4041
+ | "text"
4042
+ | "textPath"
4043
+ | "tspan"
4044
+ | "use"
4045
+ | "view";
4198
4046
 
4199
4047
  //
4200
4048
  // Browser Interfaces
@@ -4232,71 +4080,9 @@ declare namespace React {
4232
4080
  * Captures which component contained the exception, and its ancestors.
4233
4081
  */
4234
4082
  componentStack?: string | null;
4235
- digest?: string | null;
4236
4083
  }
4237
4084
 
4238
4085
  // Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
4239
- namespace JSX {
4240
- interface Element extends GlobalJSXElement {}
4241
- interface ElementClass extends GlobalJSXElementClass {}
4242
- interface ElementAttributesProperty extends GlobalJSXElementAttributesProperty {}
4243
- interface ElementChildrenAttribute extends GlobalJSXElementChildrenAttribute {}
4244
-
4245
- type LibraryManagedAttributes<C, P> = GlobalJSXLibraryManagedAttributes<C, P>;
4246
-
4247
- interface IntrinsicAttributes extends GlobalJSXIntrinsicAttributes {}
4248
- interface IntrinsicClassAttributes<T> extends GlobalJSXIntrinsicClassAttributes<T> {}
4249
- interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
4250
- }
4251
- }
4252
-
4253
- // naked 'any' type in a conditional type will short circuit and union both the then/else branches
4254
- // so boolean is only resolved for T = any
4255
- type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
4256
-
4257
- type ExactlyAnyPropertyKeys<T> = { [K in keyof T]: IsExactlyAny<T[K]> extends true ? K : never }[keyof T];
4258
- type NotExactlyAnyPropertyKeys<T> = Exclude<keyof T, ExactlyAnyPropertyKeys<T>>;
4259
-
4260
- // Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any
4261
- type MergePropTypes<P, T> =
4262
- // Distribute over P in case it is a union type
4263
- P extends any
4264
- // If props is type any, use propTypes definitions
4265
- ? IsExactlyAny<P> extends true ? T
4266
- // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
4267
- : string extends keyof P ? P
4268
- // Prefer declared types which are not exactly any
4269
- :
4270
- & Pick<P, NotExactlyAnyPropertyKeys<P>>
4271
- // For props which are exactly any, use the type inferred from propTypes if present
4272
- & Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
4273
- // Keep leftover props not specified in propTypes
4274
- & Pick<P, Exclude<keyof P, keyof T>>
4275
- : never;
4276
-
4277
- type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4278
-
4279
- // Any prop that has a default prop becomes optional, but its type is unchanged
4280
- // Undeclared default props are augmented into the resulting allowable attributes
4281
- // If declared props have indexed properties, ignore default props entirely as keyof gets widened
4282
- // Wrap in an outer-level conditional type to allow distribution over props that are unions
4283
- type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4284
- :
4285
- & Pick<P, Exclude<keyof P, keyof D>>
4286
- & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4287
- & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4288
- : never;
4289
-
4290
- type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D }
4291
- ? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
4292
- : C extends { propTypes: infer T } ? MergePropTypes<P, PropTypes.InferProps<T>>
4293
- : C extends { defaultProps: infer D } ? Defaultize<P, D>
4294
- : P;
4295
-
4296
- declare global {
4297
- /**
4298
- * @deprecated Use `React.JSX` instead of the global `JSX` namespace.
4299
- */
4300
4086
  namespace JSX {
4301
4087
  interface Element extends React.ReactElement<any, any> {}
4302
4088
  interface ElementClass extends React.Component<any> {
@@ -4508,17 +4294,18 @@ declare global {
4508
4294
  }
4509
4295
  }
4510
4296
 
4511
- // React.JSX needs to point to global.JSX to keep global module augmentations intact.
4512
- // But we can't access global.JSX so we need to create these aliases instead.
4513
- // Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
4514
- interface GlobalJSXElement extends JSX.Element {}
4515
- interface GlobalJSXElementClass extends JSX.ElementClass {}
4516
- interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
4517
- interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
4518
-
4519
- type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
4297
+ type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4520
4298
 
4521
- interface GlobalJSXIntrinsicAttributes extends JSX.IntrinsicAttributes {}
4522
- interface GlobalJSXIntrinsicClassAttributes<T> extends JSX.IntrinsicClassAttributes<T> {}
4299
+ // Any prop that has a default prop becomes optional, but its type is unchanged
4300
+ // Undeclared default props are augmented into the resulting allowable attributes
4301
+ // If declared props have indexed properties, ignore default props entirely as keyof gets widened
4302
+ // Wrap in an outer-level conditional type to allow distribution over props that are unions
4303
+ type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4304
+ :
4305
+ & Pick<P, Exclude<keyof P, keyof D>>
4306
+ & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4307
+ & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4308
+ : never;
4523
4309
 
4524
- interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}
4310
+ type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
4311
+ : P;