@types/react 18.3.1 → 19.2.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,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;
1053
+ (props: P): ReactElement<any, any> | null;
1135
1054
  /**
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;
1144
- /**
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,62 +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];
1895
- /**
1896
- * An alternative to `useState`.
1897
- *
1898
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1899
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1900
- * updates because you can pass `dispatch` down instead of callbacks.
1901
- *
1902
- * @version 16.8.0
1903
- * @see {@link https://react.dev/reference/react/useReducer}
1904
- */
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>>];
1698
+ function useReducer<S, A extends AnyActionArg>(
1699
+ reducer: (prevState: S, ...args: A) => S,
1700
+ initialState: S,
1701
+ ): [S, ActionDispatch<A>];
1945
1702
  /**
1946
1703
  * An alternative to `useState`.
1947
1704
  *
@@ -1952,21 +1709,11 @@ declare namespace React {
1952
1709
  * @version 16.8.0
1953
1710
  * @see {@link https://react.dev/reference/react/useReducer}
1954
1711
  */
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,68 @@ 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
+ export type Usable<T> = PromiseLike<T> | Context<T>;
1929
+
1930
+ export function use<T>(usable: Usable<T>): T;
1931
+
1932
+ export function useActionState<State>(
1933
+ action: (state: Awaited<State>) => State | Promise<State>,
1934
+ initialState: Awaited<State>,
1935
+ permalink?: string,
1936
+ ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
1937
+ export function useActionState<State, Payload>(
1938
+ action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
1939
+ initialState: Awaited<State>,
1940
+ permalink?: string,
1941
+ ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1942
+
1943
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1944
+ export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
1945
+
1946
+ export interface CacheSignal {}
1947
+ /**
1948
+ * @version 19.2.0
1949
+ */
1950
+ export function cacheSignal(): null | CacheSignal;
1951
+
1952
+ export interface ActivityProps {
1953
+ /**
1954
+ * @default "visible"
1955
+ */
1956
+ mode?:
1957
+ | "hidden"
1958
+ | "visible"
1959
+ | undefined;
1960
+ /**
1961
+ * A name for this Activity boundary for instrumentation purposes.
1962
+ * The name will help identify this boundary in React DevTools.
1963
+ */
1964
+ name?: string | undefined;
1965
+ children: ReactNode;
1966
+ }
1967
+
1968
+ /**
1969
+ * @see {@link https://react.dev/reference/react/Activity `<Activity>` documentation}
1970
+ * @version 19.2.0
1971
+ */
1972
+ export const Activity: ExoticComponent<ActivityProps>;
1973
+
1974
+ /**
1975
+ * Warning: Only available in development builds.
1976
+ *
1977
+ * @see {@link https://react.dev/reference/react/captureOwnerStack Reference docs}
1978
+ * @version 19.1.0
1979
+ */
1980
+ function captureOwnerStack(): string | null;
1981
+
2168
1982
  //
2169
1983
  // Event System
2170
1984
  // ----------------------------------------------------------------------
@@ -2237,6 +2051,10 @@ declare namespace React {
2237
2051
  target: EventTarget & T;
2238
2052
  }
2239
2053
 
2054
+ interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
2055
+ data: string;
2056
+ }
2057
+
2240
2058
  export type ModifierKey =
2241
2059
  | "Alt"
2242
2060
  | "AltGraph"
@@ -2332,6 +2150,11 @@ declare namespace React {
2332
2150
  pseudoElement: string;
2333
2151
  }
2334
2152
 
2153
+ interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
2154
+ oldState: "closed" | "open";
2155
+ newState: "closed" | "open";
2156
+ }
2157
+
2335
2158
  interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
2336
2159
  elapsedTime: number;
2337
2160
  propertyName: string;
@@ -2352,6 +2175,7 @@ declare namespace React {
2352
2175
  type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
2353
2176
  type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
2354
2177
  type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
2178
+ type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
2355
2179
  type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
2356
2180
  type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
2357
2181
  type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
@@ -2359,6 +2183,7 @@ declare namespace React {
2359
2183
  type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
2360
2184
  type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
2361
2185
  type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
2186
+ type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
2362
2187
  type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
2363
2188
 
2364
2189
  //
@@ -2409,7 +2234,7 @@ declare namespace React {
2409
2234
  // Form Events
2410
2235
  onChange?: FormEventHandler<T> | undefined;
2411
2236
  onChangeCapture?: FormEventHandler<T> | undefined;
2412
- onBeforeInput?: FormEventHandler<T> | undefined;
2237
+ onBeforeInput?: InputEventHandler<T> | undefined;
2413
2238
  onBeforeInputCapture?: FormEventHandler<T> | undefined;
2414
2239
  onInput?: FormEventHandler<T> | undefined;
2415
2240
  onInputCapture?: FormEventHandler<T> | undefined;
@@ -2429,9 +2254,9 @@ declare namespace React {
2429
2254
  // Keyboard Events
2430
2255
  onKeyDown?: KeyboardEventHandler<T> | undefined;
2431
2256
  onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
2432
- /** @deprecated */
2257
+ /** @deprecated Use `onKeyUp` or `onKeyDown` instead */
2433
2258
  onKeyPress?: KeyboardEventHandler<T> | undefined;
2434
- /** @deprecated */
2259
+ /** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
2435
2260
  onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
2436
2261
  onKeyUp?: KeyboardEventHandler<T> | undefined;
2437
2262
  onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
@@ -2467,8 +2292,6 @@ declare namespace React {
2467
2292
  onProgressCapture?: ReactEventHandler<T> | undefined;
2468
2293
  onRateChange?: ReactEventHandler<T> | undefined;
2469
2294
  onRateChangeCapture?: ReactEventHandler<T> | undefined;
2470
- onResize?: ReactEventHandler<T> | undefined;
2471
- onResizeCapture?: ReactEventHandler<T> | undefined;
2472
2295
  onSeeked?: ReactEventHandler<T> | undefined;
2473
2296
  onSeekedCapture?: ReactEventHandler<T> | undefined;
2474
2297
  onSeeking?: ReactEventHandler<T> | undefined;
@@ -2559,6 +2382,8 @@ declare namespace React {
2559
2382
  // UI Events
2560
2383
  onScroll?: UIEventHandler<T> | undefined;
2561
2384
  onScrollCapture?: UIEventHandler<T> | undefined;
2385
+ onScrollEnd?: UIEventHandler<T> | undefined;
2386
+ onScrollEndCapture?: UIEventHandler<T> | undefined;
2562
2387
 
2563
2388
  // Wheel Events
2564
2389
  onWheel?: WheelEventHandler<T> | undefined;
@@ -2572,9 +2397,19 @@ declare namespace React {
2572
2397
  onAnimationIteration?: AnimationEventHandler<T> | undefined;
2573
2398
  onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
2574
2399
 
2400
+ // Toggle Events
2401
+ onToggle?: ToggleEventHandler<T> | undefined;
2402
+ onBeforeToggle?: ToggleEventHandler<T> | undefined;
2403
+
2575
2404
  // Transition Events
2405
+ onTransitionCancel?: TransitionEventHandler<T> | undefined;
2406
+ onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
2576
2407
  onTransitionEnd?: TransitionEventHandler<T> | undefined;
2577
2408
  onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
2409
+ onTransitionRun?: TransitionEventHandler<T> | undefined;
2410
+ onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
2411
+ onTransitionStart?: TransitionEventHandler<T> | undefined;
2412
+ onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
2578
2413
  }
2579
2414
 
2580
2415
  export interface CSSProperties extends CSS.Properties<string | number> {
@@ -2894,12 +2729,14 @@ declare namespace React {
2894
2729
 
2895
2730
  // Standard HTML Attributes
2896
2731
  accessKey?: string | undefined;
2732
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
2897
2733
  autoFocus?: boolean | undefined;
2898
2734
  className?: string | undefined;
2899
2735
  contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
2900
2736
  contextMenu?: string | undefined;
2901
2737
  dir?: string | undefined;
2902
2738
  draggable?: Booleanish | undefined;
2739
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
2903
2740
  hidden?: boolean | undefined;
2904
2741
  id?: string | undefined;
2905
2742
  lang?: string | undefined;
@@ -2931,7 +2768,6 @@ declare namespace React {
2931
2768
  vocab?: string | undefined;
2932
2769
 
2933
2770
  // Non-standard Attributes
2934
- autoCapitalize?: string | undefined;
2935
2771
  autoCorrect?: string | undefined;
2936
2772
  autoSave?: string | undefined;
2937
2773
  color?: string | undefined;
@@ -2944,7 +2780,16 @@ declare namespace React {
2944
2780
  security?: string | undefined;
2945
2781
  unselectable?: "on" | "off" | undefined;
2946
2782
 
2783
+ // Popover API
2784
+ popover?: "" | "auto" | "manual" | "hint" | undefined;
2785
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
2786
+ popoverTarget?: string | undefined;
2787
+
2947
2788
  // Living Standard
2789
+ /**
2790
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
2791
+ */
2792
+ inert?: boolean | undefined;
2948
2793
  /**
2949
2794
  * Hints at the type of data that might be entered by the user while editing the element or its contents
2950
2795
  * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
@@ -2955,6 +2800,14 @@ declare namespace React {
2955
2800
  * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
2956
2801
  */
2957
2802
  is?: string | undefined;
2803
+ /**
2804
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2805
+ */
2806
+ exportparts?: string | undefined;
2807
+ /**
2808
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2809
+ */
2810
+ part?: string | undefined;
2958
2811
  }
2959
2812
 
2960
2813
  /**
@@ -2971,6 +2824,7 @@ declare namespace React {
2971
2824
  action?:
2972
2825
  | string
2973
2826
  | undefined
2827
+ | ((formData: FormData) => void | Promise<void>)
2974
2828
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2975
2829
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2976
2830
  ];
@@ -3005,6 +2859,7 @@ declare namespace React {
3005
2859
  formAction?:
3006
2860
  | string
3007
2861
  | undefined
2862
+ | ((formData: FormData) => void | Promise<void>)
3008
2863
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3009
2864
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3010
2865
  ];
@@ -3137,6 +2992,7 @@ declare namespace React {
3137
2992
  form?: string | undefined;
3138
2993
  formAction?:
3139
2994
  | string
2995
+ | ((formData: FormData) => void | Promise<void>)
3140
2996
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3141
2997
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3142
2998
  ]
@@ -3170,7 +3026,6 @@ declare namespace React {
3170
3026
 
3171
3027
  interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
3172
3028
  open?: boolean | undefined;
3173
- onToggle?: ReactEventHandler<T> | undefined;
3174
3029
  name?: string | undefined;
3175
3030
  }
3176
3031
 
@@ -3203,6 +3058,7 @@ declare namespace React {
3203
3058
  action?:
3204
3059
  | string
3205
3060
  | undefined
3061
+ | ((formData: FormData) => void | Promise<void>)
3206
3062
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3207
3063
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3208
3064
  ];
@@ -3241,6 +3097,8 @@ declare namespace React {
3241
3097
  width?: number | string | undefined;
3242
3098
  }
3243
3099
 
3100
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {}
3101
+
3244
3102
  interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
3245
3103
  alt?: string | undefined;
3246
3104
  crossOrigin?: CrossOrigin;
@@ -3250,7 +3108,12 @@ declare namespace React {
3250
3108
  loading?: "eager" | "lazy" | undefined;
3251
3109
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3252
3110
  sizes?: string | undefined;
3253
- src?: string | undefined;
3111
+ src?:
3112
+ | string
3113
+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES[
3114
+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES
3115
+ ]
3116
+ | undefined;
3254
3117
  srcSet?: string | undefined;
3255
3118
  useMap?: string | undefined;
3256
3119
  width?: number | string | undefined;
@@ -3355,10 +3218,10 @@ declare namespace React {
3355
3218
  capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3356
3219
  checked?: boolean | undefined;
3357
3220
  disabled?: boolean | undefined;
3358
- enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
3359
3221
  form?: string | undefined;
3360
3222
  formAction?:
3361
3223
  | string
3224
+ | ((formData: FormData) => void | Promise<void>)
3362
3225
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3363
3226
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3364
3227
  ]
@@ -3409,6 +3272,7 @@ declare namespace React {
3409
3272
 
3410
3273
  interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
3411
3274
  as?: string | undefined;
3275
+ blocking?: "render" | (string & {}) | undefined;
3412
3276
  crossOrigin?: CrossOrigin;
3413
3277
  fetchPriority?: "high" | "low" | "auto";
3414
3278
  href?: string | undefined;
@@ -3421,6 +3285,9 @@ declare namespace React {
3421
3285
  sizes?: string | undefined;
3422
3286
  type?: string | undefined;
3423
3287
  charSet?: string | undefined;
3288
+
3289
+ // React props
3290
+ precedence?: string | undefined;
3424
3291
  }
3425
3292
 
3426
3293
  interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3431,6 +3298,8 @@ declare namespace React {
3431
3298
  type?: string | undefined;
3432
3299
  }
3433
3300
 
3301
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {}
3302
+
3434
3303
  interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
3435
3304
  autoPlay?: boolean | undefined;
3436
3305
  controls?: boolean | undefined;
@@ -3441,7 +3310,12 @@ declare namespace React {
3441
3310
  muted?: boolean | undefined;
3442
3311
  playsInline?: boolean | undefined;
3443
3312
  preload?: string | undefined;
3444
- src?: string | undefined;
3313
+ src?:
3314
+ | string
3315
+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES[
3316
+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES
3317
+ ]
3318
+ | undefined;
3445
3319
  }
3446
3320
 
3447
3321
  interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3518,10 +3392,12 @@ declare namespace React {
3518
3392
 
3519
3393
  interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
3520
3394
  async?: boolean | undefined;
3395
+ blocking?: "render" | (string & {}) | undefined;
3521
3396
  /** @deprecated */
3522
3397
  charSet?: string | undefined;
3523
3398
  crossOrigin?: CrossOrigin;
3524
3399
  defer?: boolean | undefined;
3400
+ fetchPriority?: "high" | "low" | "auto" | undefined;
3525
3401
  integrity?: string | undefined;
3526
3402
  noModule?: boolean | undefined;
3527
3403
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
@@ -3552,9 +3428,14 @@ declare namespace React {
3552
3428
  }
3553
3429
 
3554
3430
  interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
3431
+ blocking?: "render" | (string & {}) | undefined;
3555
3432
  media?: string | undefined;
3556
3433
  scoped?: boolean | undefined;
3557
3434
  type?: string | undefined;
3435
+
3436
+ // React props
3437
+ href?: string | undefined;
3438
+ precedence?: string | undefined;
3558
3439
  }
3559
3440
 
3560
3441
  interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3628,6 +3509,9 @@ declare namespace React {
3628
3509
  width?: number | string | undefined;
3629
3510
  disablePictureInPicture?: boolean | undefined;
3630
3511
  disableRemotePlayback?: boolean | undefined;
3512
+
3513
+ onResize?: ReactEventHandler<T> | undefined;
3514
+ onResizeCapture?: ReactEventHandler<T> | undefined;
3631
3515
  }
3632
3516
 
3633
3517
  // this list is "complete" in that it contains every SVG attribute
@@ -3721,7 +3605,21 @@ declare namespace React {
3721
3605
  direction?: number | string | undefined;
3722
3606
  display?: number | string | undefined;
3723
3607
  divisor?: number | string | undefined;
3724
- dominantBaseline?: number | string | undefined;
3608
+ dominantBaseline?:
3609
+ | "auto"
3610
+ | "use-script"
3611
+ | "no-change"
3612
+ | "reset-size"
3613
+ | "ideographic"
3614
+ | "alphabetic"
3615
+ | "hanging"
3616
+ | "mathematical"
3617
+ | "central"
3618
+ | "middle"
3619
+ | "text-after-edge"
3620
+ | "text-before-edge"
3621
+ | "inherit"
3622
+ | undefined;
3725
3623
  dur?: number | string | undefined;
3726
3624
  dx?: number | string | undefined;
3727
3625
  dy?: number | string | undefined;
@@ -3868,7 +3766,7 @@ declare namespace React {
3868
3766
  tableValues?: number | string | undefined;
3869
3767
  targetX?: number | string | undefined;
3870
3768
  targetY?: number | string | undefined;
3871
- textAnchor?: string | undefined;
3769
+ textAnchor?: "start" | "middle" | "end" | "inherit" | undefined;
3872
3770
  textDecoration?: number | string | undefined;
3873
3771
  textLength?: number | string | undefined;
3874
3772
  textRendering?: number | string | undefined;
@@ -3942,259 +3840,184 @@ declare namespace React {
3942
3840
  webpreferences?: string | undefined;
3943
3841
  }
3944
3842
 
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
- }
3843
+ // TODO: Move to react-dom
3844
+ type HTMLElementType =
3845
+ | "a"
3846
+ | "abbr"
3847
+ | "address"
3848
+ | "area"
3849
+ | "article"
3850
+ | "aside"
3851
+ | "audio"
3852
+ | "b"
3853
+ | "base"
3854
+ | "bdi"
3855
+ | "bdo"
3856
+ | "big"
3857
+ | "blockquote"
3858
+ | "body"
3859
+ | "br"
3860
+ | "button"
3861
+ | "canvas"
3862
+ | "caption"
3863
+ | "center"
3864
+ | "cite"
3865
+ | "code"
3866
+ | "col"
3867
+ | "colgroup"
3868
+ | "data"
3869
+ | "datalist"
3870
+ | "dd"
3871
+ | "del"
3872
+ | "details"
3873
+ | "dfn"
3874
+ | "dialog"
3875
+ | "div"
3876
+ | "dl"
3877
+ | "dt"
3878
+ | "em"
3879
+ | "embed"
3880
+ | "fieldset"
3881
+ | "figcaption"
3882
+ | "figure"
3883
+ | "footer"
3884
+ | "form"
3885
+ | "h1"
3886
+ | "h2"
3887
+ | "h3"
3888
+ | "h4"
3889
+ | "h5"
3890
+ | "h6"
3891
+ | "head"
3892
+ | "header"
3893
+ | "hgroup"
3894
+ | "hr"
3895
+ | "html"
3896
+ | "i"
3897
+ | "iframe"
3898
+ | "img"
3899
+ | "input"
3900
+ | "ins"
3901
+ | "kbd"
3902
+ | "keygen"
3903
+ | "label"
3904
+ | "legend"
3905
+ | "li"
3906
+ | "link"
3907
+ | "main"
3908
+ | "map"
3909
+ | "mark"
3910
+ | "menu"
3911
+ | "menuitem"
3912
+ | "meta"
3913
+ | "meter"
3914
+ | "nav"
3915
+ | "noscript"
3916
+ | "object"
3917
+ | "ol"
3918
+ | "optgroup"
3919
+ | "option"
3920
+ | "output"
3921
+ | "p"
3922
+ | "param"
3923
+ | "picture"
3924
+ | "pre"
3925
+ | "progress"
3926
+ | "q"
3927
+ | "rp"
3928
+ | "rt"
3929
+ | "ruby"
3930
+ | "s"
3931
+ | "samp"
3932
+ | "search"
3933
+ | "slot"
3934
+ | "script"
3935
+ | "section"
3936
+ | "select"
3937
+ | "small"
3938
+ | "source"
3939
+ | "span"
3940
+ | "strong"
3941
+ | "style"
3942
+ | "sub"
3943
+ | "summary"
3944
+ | "sup"
3945
+ | "table"
3946
+ | "template"
3947
+ | "tbody"
3948
+ | "td"
3949
+ | "textarea"
3950
+ | "tfoot"
3951
+ | "th"
3952
+ | "thead"
3953
+ | "time"
3954
+ | "title"
3955
+ | "tr"
3956
+ | "track"
3957
+ | "u"
3958
+ | "ul"
3959
+ | "var"
3960
+ | "video"
3961
+ | "wbr"
3962
+ | "webview";
3963
+
3964
+ // TODO: Move to react-dom
3965
+ type SVGElementType =
3966
+ | "animate"
3967
+ | "circle"
3968
+ | "clipPath"
3969
+ | "defs"
3970
+ | "desc"
3971
+ | "ellipse"
3972
+ | "feBlend"
3973
+ | "feColorMatrix"
3974
+ | "feComponentTransfer"
3975
+ | "feComposite"
3976
+ | "feConvolveMatrix"
3977
+ | "feDiffuseLighting"
3978
+ | "feDisplacementMap"
3979
+ | "feDistantLight"
3980
+ | "feDropShadow"
3981
+ | "feFlood"
3982
+ | "feFuncA"
3983
+ | "feFuncB"
3984
+ | "feFuncG"
3985
+ | "feFuncR"
3986
+ | "feGaussianBlur"
3987
+ | "feImage"
3988
+ | "feMerge"
3989
+ | "feMergeNode"
3990
+ | "feMorphology"
3991
+ | "feOffset"
3992
+ | "fePointLight"
3993
+ | "feSpecularLighting"
3994
+ | "feSpotLight"
3995
+ | "feTile"
3996
+ | "feTurbulence"
3997
+ | "filter"
3998
+ | "foreignObject"
3999
+ | "g"
4000
+ | "image"
4001
+ | "line"
4002
+ | "linearGradient"
4003
+ | "marker"
4004
+ | "mask"
4005
+ | "metadata"
4006
+ | "path"
4007
+ | "pattern"
4008
+ | "polygon"
4009
+ | "polyline"
4010
+ | "radialGradient"
4011
+ | "rect"
4012
+ | "stop"
4013
+ | "svg"
4014
+ | "switch"
4015
+ | "symbol"
4016
+ | "text"
4017
+ | "textPath"
4018
+ | "tspan"
4019
+ | "use"
4020
+ | "view";
4198
4021
 
4199
4022
  //
4200
4023
  // Browser Interfaces
@@ -4236,67 +4059,6 @@ declare namespace React {
4236
4059
  }
4237
4060
 
4238
4061
  // 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
4062
  namespace JSX {
4301
4063
  interface Element extends React.ReactElement<any, any> {}
4302
4064
  interface ElementClass extends React.Component<any> {
@@ -4508,17 +4270,18 @@ declare global {
4508
4270
  }
4509
4271
  }
4510
4272
 
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>;
4273
+ type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4520
4274
 
4521
- interface GlobalJSXIntrinsicAttributes extends JSX.IntrinsicAttributes {}
4522
- interface GlobalJSXIntrinsicClassAttributes<T> extends JSX.IntrinsicClassAttributes<T> {}
4275
+ // Any prop that has a default prop becomes optional, but its type is unchanged
4276
+ // Undeclared default props are augmented into the resulting allowable attributes
4277
+ // If declared props have indexed properties, ignore default props entirely as keyof gets widened
4278
+ // Wrap in an outer-level conditional type to allow distribution over props that are unions
4279
+ type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4280
+ :
4281
+ & Pick<P, Exclude<keyof P, keyof D>>
4282
+ & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4283
+ & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4284
+ : never;
4523
4285
 
4524
- interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}
4286
+ type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
4287
+ : P;