@types/react 18.3.1 → 19.1.10

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/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
- ) => ReactNode)
125
- | (new(
126
- props: P,
127
- /**
128
- * @deprecated
129
- *
130
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
131
- */
132
- deprecatedLegacyContext?: any,
133
- ) => Component<any, any>);
136
+ ) => ReactNode | Promise<ReactNode>)
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) => ReactNode)
221
+ | { new(props: any, context: any): Component<any> }
222
+ | ((props: any) => ReactNode)
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
  * Different release channels declare additional types of ReactNode this particular release channel accepts.
444
393
  * App or library types should never augment this interface.
@@ -479,6 +428,7 @@ declare namespace React {
479
428
  | ReactElement
480
429
  | string
481
430
  | number
431
+ | bigint
482
432
  | Iterable<ReactNode>
483
433
  | ReactPortal
484
434
  | boolean
@@ -486,36 +436,13 @@ declare namespace React {
486
436
  | undefined
487
437
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
488
438
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
489
- ];
439
+ ]
440
+ | Promise<AwaitedReactNode>;
490
441
 
491
442
  //
492
443
  // Top Level API
493
444
  // ----------------------------------------------------------------------
494
445
 
495
- // DOM Elements
496
- /** @deprecated */
497
- function createFactory<T extends HTMLElement>(
498
- type: keyof ReactHTML,
499
- ): HTMLFactory<T>;
500
- /** @deprecated */
501
- function createFactory(
502
- type: keyof ReactSVG,
503
- ): SVGFactory;
504
- /** @deprecated */
505
- function createFactory<P extends DOMAttributes<T>, T extends Element>(
506
- type: string,
507
- ): DOMFactory<P, T>;
508
-
509
- // Custom components
510
- /** @deprecated */
511
- function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
512
- /** @deprecated */
513
- function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
514
- type: ClassType<P, T, C>,
515
- ): CFactory<P, T>;
516
- /** @deprecated */
517
- function createFactory<P>(type: ComponentClass<P>): Factory<P>;
518
-
519
446
  // DOM Elements
520
447
  // TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
521
448
  function createElement(
@@ -524,12 +451,12 @@ declare namespace React {
524
451
  ...children: ReactNode[]
525
452
  ): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
526
453
  function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
527
- type: keyof ReactHTML,
454
+ type: HTMLElementType,
528
455
  props?: ClassAttributes<T> & P | null,
529
456
  ...children: ReactNode[]
530
457
  ): DetailedReactHTMLElement<P, T>;
531
458
  function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
532
- type: keyof ReactSVG,
459
+ type: SVGElementType,
533
460
  props?: ClassAttributes<T> & P | null,
534
461
  ...children: ReactNode[]
535
462
  ): ReactSVGElement;
@@ -658,7 +585,6 @@ declare namespace React {
658
585
  * @template P The props the component accepts.
659
586
  */
660
587
  interface ProviderExoticComponent<P> extends ExoticComponent<P> {
661
- propTypes?: WeakValidationMap<P> | undefined;
662
588
  }
663
589
 
664
590
  /**
@@ -740,7 +666,7 @@ declare namespace React {
740
666
  * const ThemeContext = createContext('light');
741
667
  * ```
742
668
  */
743
- interface Context<T> {
669
+ interface Context<T> extends Provider<T> {
744
670
  Provider: Provider<T>;
745
671
  Consumer: Consumer<T>;
746
672
  /**
@@ -769,6 +695,13 @@ declare namespace React {
769
695
  * import { createContext } from 'react';
770
696
  *
771
697
  * const ThemeContext = createContext('light');
698
+ * function App() {
699
+ * return (
700
+ * <ThemeContext value="dark">
701
+ * <Toolbar />
702
+ * </ThemeContext>
703
+ * );
704
+ * }
772
705
  * ```
773
706
  */
774
707
  function createContext<T>(
@@ -779,9 +712,6 @@ declare namespace React {
779
712
 
780
713
  function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
781
714
 
782
- /**
783
- * Maintainer's note: Sync with {@link ReactChildren} until {@link ReactChildren} is removed.
784
- */
785
715
  const Children: {
786
716
  map<T, C>(
787
717
  children: C | readonly C[],
@@ -792,6 +722,10 @@ declare namespace React {
792
722
  only<C>(children: C): C extends any[] ? never : C;
793
723
  toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
794
724
  };
725
+
726
+ export interface FragmentProps {
727
+ children?: React.ReactNode;
728
+ }
795
729
  /**
796
730
  * Lets you group elements without a wrapper node.
797
731
  *
@@ -819,7 +753,7 @@ declare namespace React {
819
753
  * </>
820
754
  * ```
821
755
  */
822
- const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
756
+ const Fragment: ExoticComponent<FragmentProps>;
823
757
 
824
758
  /**
825
759
  * Lets you find common bugs in your components early during development.
@@ -848,6 +782,12 @@ declare namespace React {
848
782
 
849
783
  /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
850
784
  fallback?: ReactNode;
785
+
786
+ /**
787
+ * A name for this Suspense boundary for instrumentation purposes.
788
+ * The name will help identify this boundary in React DevTools.
789
+ */
790
+ name?: string | undefined;
851
791
  }
852
792
 
853
793
  /**
@@ -982,7 +922,13 @@ declare namespace React {
982
922
  static contextType?: Context<any> | undefined;
983
923
 
984
924
  /**
985
- * If using the new style context, re-declare this in your class to be the
925
+ * Ignored by React.
926
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
927
+ */
928
+ static propTypes?: any;
929
+
930
+ /**
931
+ * If using React Context, re-declare this in your class to be the
986
932
  * `React.ContextType` of your `static contextType`.
987
933
  * Should be used with type annotation or static contextType.
988
934
  *
@@ -999,11 +945,15 @@ declare namespace React {
999
945
  */
1000
946
  context: unknown;
1001
947
 
948
+ // Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
1002
949
  constructor(props: P);
1003
950
  /**
1004
- * @deprecated
1005
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}
951
+ * @param props
952
+ * @param context value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
953
+ * in `contextType`.
1006
954
  */
955
+ // TODO: Ideally we'd infer the constructor signatur from `contextType`.
956
+ // Might be hard to ship without breaking existing code.
1007
957
  constructor(props: P, context: any);
1008
958
 
1009
959
  // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
@@ -1019,14 +969,6 @@ declare namespace React {
1019
969
 
1020
970
  readonly props: Readonly<P>;
1021
971
  state: Readonly<S>;
1022
- /**
1023
- * @deprecated
1024
- *
1025
- * @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
1026
- */
1027
- refs: {
1028
- [key: string]: ReactInstance;
1029
- };
1030
972
  }
1031
973
 
1032
974
  class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
@@ -1043,10 +985,6 @@ declare namespace React {
1043
985
  getInitialState?(): S;
1044
986
  }
1045
987
 
1046
- interface ChildContextProvider<CC> {
1047
- getChildContext(): CC;
1048
- }
1049
-
1050
988
  //
1051
989
  // Class Interfaces
1052
990
  // ----------------------------------------------------------------------
@@ -1111,58 +1049,12 @@ declare namespace React {
1111
1049
  * ```
1112
1050
  */
1113
1051
  interface FunctionComponent<P = {}> {
1114
- (
1115
- props: P,
1116
- /**
1117
- * @deprecated
1118
- *
1119
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1120
- */
1121
- deprecatedLegacyContext?: any,
1122
- ): ReactNode;
1123
- /**
1124
- * Used to declare the types of the props accepted by the
1125
- * component. These types will be checked during rendering
1126
- * and in development only.
1127
- *
1128
- * We recommend using TypeScript instead of checking prop
1129
- * types at runtime.
1130
- *
1131
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1132
- */
1133
- propTypes?: WeakValidationMap<P> | undefined;
1052
+ (props: P): ReactNode | Promise<ReactNode>;
1134
1053
  /**
1135
- * @deprecated
1136
- *
1137
- * Lets you specify which legacy context is consumed by
1138
- * this component.
1139
- *
1140
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
1054
+ * Ignored by React.
1055
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1141
1056
  */
1142
- contextTypes?: ValidationMap<any> | undefined;
1143
- /**
1144
- * Used to define default values for the props accepted by
1145
- * the component.
1146
- *
1147
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1148
- *
1149
- * @example
1150
- *
1151
- * ```tsx
1152
- * type Props = { name?: string }
1153
- *
1154
- * const MyComponent: FC<Props> = (props) => {
1155
- * return <div>{props.name}</div>
1156
- * }
1157
- *
1158
- * MyComponent.defaultProps = {
1159
- * name: 'John Doe'
1160
- * }
1161
- * ```
1162
- *
1163
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1164
- */
1165
- defaultProps?: Partial<P> | undefined;
1057
+ propTypes?: any;
1166
1058
  /**
1167
1059
  * Used in debugging messages. You might want to set it
1168
1060
  * explicitly if you want to display a different name for
@@ -1184,44 +1076,14 @@ declare namespace React {
1184
1076
  displayName?: string | undefined;
1185
1077
  }
1186
1078
 
1187
- /**
1188
- * @deprecated - Equivalent to {@link React.FunctionComponent}.
1189
- *
1190
- * @see {@link React.FunctionComponent}
1191
- * @alias {@link VoidFunctionComponent}
1192
- */
1193
- type VFC<P = {}> = VoidFunctionComponent<P>;
1194
-
1195
- /**
1196
- * @deprecated - Equivalent to {@link React.FunctionComponent}.
1197
- *
1198
- * @see {@link React.FunctionComponent}
1199
- */
1200
- interface VoidFunctionComponent<P = {}> {
1201
- (
1202
- props: P,
1203
- /**
1204
- * @deprecated
1205
- *
1206
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1207
- */
1208
- deprecatedLegacyContext?: any,
1209
- ): ReactNode;
1210
- propTypes?: WeakValidationMap<P> | undefined;
1211
- contextTypes?: ValidationMap<any> | undefined;
1212
- /**
1213
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1214
- */
1215
- defaultProps?: Partial<P> | undefined;
1216
- displayName?: string | undefined;
1217
- }
1218
-
1219
1079
  /**
1220
1080
  * The type of the ref received by a {@link ForwardRefRenderFunction}.
1221
1081
  *
1222
1082
  * @see {@link ForwardRefRenderFunction}
1223
1083
  */
1224
- type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
1084
+ // Making T nullable is assuming the refs will be managed by React or the component impl will write it somewhere else.
1085
+ // But this isn't necessarily true. We haven't heard complains about it yet and hopefully `forwardRef` is removed from React before we do.
1086
+ type ForwardedRef<T> = ((instance: T | null) => void) | RefObject<T | null> | null;
1225
1087
 
1226
1088
  /**
1227
1089
  * The type of the function passed to {@link forwardRef}. This is considered different
@@ -1250,19 +1112,10 @@ declare namespace React {
1250
1112
  */
1251
1113
  displayName?: string | undefined;
1252
1114
  /**
1253
- * defaultProps are not supported on render functions passed to forwardRef.
1254
- *
1255
- * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
1256
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1115
+ * Ignored by React.
1116
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1257
1117
  */
1258
- defaultProps?: never | undefined;
1259
- /**
1260
- * propTypes are not supported on render functions passed to forwardRef.
1261
- *
1262
- * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
1263
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1264
- */
1265
- propTypes?: never | undefined;
1118
+ propTypes?: any;
1266
1119
  }
1267
1120
 
1268
1121
  /**
@@ -1272,48 +1125,21 @@ declare namespace React {
1272
1125
  * @template S The internal state of the component.
1273
1126
  */
1274
1127
  interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
1128
+ // constructor signature must match React.Component
1275
1129
  new(
1276
1130
  props: P,
1277
1131
  /**
1278
- * @deprecated
1279
- *
1280
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
1132
+ * Value of the parent {@link https://react.dev/reference/react/Component#context Context} specified
1133
+ * in `contextType`.
1281
1134
  */
1282
- deprecatedLegacyContext?: any,
1135
+ context?: any,
1283
1136
  ): Component<P, S>;
1284
1137
  /**
1285
- * Used to declare the types of the props accepted by the
1286
- * component. These types will be checked during rendering
1287
- * and in development only.
1288
- *
1289
- * We recommend using TypeScript instead of checking prop
1290
- * types at runtime.
1291
- *
1292
- * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
1138
+ * Ignored by React.
1139
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1293
1140
  */
1294
- propTypes?: WeakValidationMap<P> | undefined;
1141
+ propTypes?: any;
1295
1142
  contextType?: Context<any> | undefined;
1296
- /**
1297
- * @deprecated use {@link ComponentClass.contextType} instead
1298
- *
1299
- * Lets you specify which legacy context is consumed by
1300
- * this component.
1301
- *
1302
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs}
1303
- */
1304
- contextTypes?: ValidationMap<any> | undefined;
1305
- /**
1306
- * @deprecated
1307
- *
1308
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs}
1309
- */
1310
- childContextTypes?: ValidationMap<any> | undefined;
1311
- /**
1312
- * Used to define default values for the props accepted by
1313
- * the component.
1314
- *
1315
- * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
1316
- */
1317
1143
  defaultProps?: Partial<P> | undefined;
1318
1144
  /**
1319
1145
  * Used in debugging messages. You might want to set it
@@ -1332,7 +1158,7 @@ declare namespace React {
1332
1158
  * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
1333
1159
  */
1334
1160
  interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
1335
- new(props: P, deprecatedLegacyContext?: any): ClassicComponent<P, ComponentState>;
1161
+ new(props: P): ClassicComponent<P, ComponentState>;
1336
1162
  getDefaultProps?(): P;
1337
1163
  }
1338
1164
 
@@ -1347,7 +1173,7 @@ declare namespace React {
1347
1173
  */
1348
1174
  type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
1349
1175
  & C
1350
- & (new(props: P, deprecatedLegacyContext?: any) => T);
1176
+ & (new(props: P, context: any) => T);
1351
1177
 
1352
1178
  //
1353
1179
  // Component Specs and Lifecycle
@@ -1521,38 +1347,7 @@ declare namespace React {
1521
1347
  UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
1522
1348
  }
1523
1349
 
1524
- /**
1525
- * @deprecated
1526
- *
1527
- * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1528
- */
1529
- interface Mixin<P, S> extends ComponentLifecycle<P, S> {
1530
- mixins?: Array<Mixin<P, S>> | undefined;
1531
- statics?: {
1532
- [key: string]: any;
1533
- } | undefined;
1534
-
1535
- displayName?: string | undefined;
1536
- propTypes?: ValidationMap<any> | undefined;
1537
- contextTypes?: ValidationMap<any> | undefined;
1538
- childContextTypes?: ValidationMap<any> | undefined;
1539
-
1540
- getDefaultProps?(): P;
1541
- getInitialState?(): S;
1542
- }
1543
-
1544
- /**
1545
- * @deprecated
1546
- *
1547
- * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1548
- */
1549
- interface ComponentSpec<P, S> extends Mixin<P, S> {
1550
- render(): ReactNode;
1551
-
1552
- [propertyName: string]: any;
1553
- }
1554
-
1555
- function createRef<T>(): RefObject<T>;
1350
+ function createRef<T>(): RefObject<T | null>;
1556
1351
 
1557
1352
  /**
1558
1353
  * The type of the component returned from {@link forwardRef}.
@@ -1563,10 +1358,10 @@ declare namespace React {
1563
1358
  */
1564
1359
  interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
1565
1360
  /**
1566
- * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
1361
+ * Ignored by React.
1362
+ * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1567
1363
  */
1568
- defaultProps?: Partial<P> | undefined;
1569
- propTypes?: WeakValidationMap<P> | undefined;
1364
+ propTypes?: any;
1570
1365
  }
1571
1366
 
1572
1367
  /**
@@ -1597,29 +1392,24 @@ declare namespace React {
1597
1392
  * ```
1598
1393
  */
1599
1394
  function forwardRef<T, P = {}>(
1600
- render: ForwardRefRenderFunction<T, P>,
1395
+ render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
1601
1396
  ): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
1602
1397
 
1603
1398
  /**
1604
1399
  * Omits the 'ref' attribute from the given props object.
1605
1400
  *
1606
- * @template P The props object type.
1401
+ * @template Props The props object type.
1607
1402
  */
1608
- type PropsWithoutRef<P> =
1403
+ type PropsWithoutRef<Props> =
1609
1404
  // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
1610
1405
  // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
1611
1406
  // https://github.com/Microsoft/TypeScript/issues/28339
1612
- P extends any ? ("ref" extends keyof P ? Omit<P, "ref"> : P) : P;
1613
- /** Ensures that the props do not include string ref, which cannot be forwarded */
1614
- type PropsWithRef<P> =
1615
- // Note: String refs can be forwarded. We can't fix this bug without breaking a bunch of libraries now though.
1616
- // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
1617
- "ref" extends keyof P
1618
- ? P extends { ref?: infer R | undefined }
1619
- ? string extends R ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
1620
- : P
1621
- : P
1622
- : P;
1407
+ Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
1408
+ /**
1409
+ * Ensures that the props do not include string ref, which cannot be forwarded
1410
+ * @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
1411
+ */
1412
+ type PropsWithRef<Props> = Props;
1623
1413
 
1624
1414
  type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
1625
1415
 
@@ -1651,7 +1441,7 @@ declare namespace React {
1651
1441
  * ```
1652
1442
  */
1653
1443
  type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
1654
- JSXElementConstructor<infer P> ? P
1444
+ JSXElementConstructor<infer Props> ? Props
1655
1445
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
1656
1446
  : {};
1657
1447
 
@@ -1678,9 +1468,11 @@ declare namespace React {
1678
1468
  * type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
1679
1469
  * ```
1680
1470
  */
1681
- type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
1682
- ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
1683
- : PropsWithRef<ComponentProps<T>>;
1471
+ type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
1472
+ // If it's a class i.e. newable we're dealing with a class component
1473
+ ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1474
+ : Props
1475
+ : ComponentProps<T>;
1684
1476
  /**
1685
1477
  * Used to retrieve the props a custom component accepts with its ref.
1686
1478
  *
@@ -1697,9 +1489,10 @@ declare namespace React {
1697
1489
  * type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
1698
1490
  * ```
1699
1491
  */
1700
- type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
1701
- ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
1702
- : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
1492
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
1493
+ // If it's a class i.e. newable we're dealing with a class component
1494
+ ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1495
+ : Props
1703
1496
  : never;
1704
1497
 
1705
1498
  /**
@@ -1727,10 +1520,24 @@ declare namespace React {
1727
1520
  */
1728
1521
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
1729
1522
 
1730
- type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
1731
- ComponentPropsWithoutRef<T> & RefAttributes<infer Method>
1732
- > ? Method
1733
- : ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1523
+ /**
1524
+ * Retrieves the type of the 'ref' prop for a given component type or tag name.
1525
+ *
1526
+ * @template C The component type.
1527
+ *
1528
+ * @example
1529
+ *
1530
+ * ```tsx
1531
+ * type MyComponentRef = React.ComponentRef<typeof MyComponent>;
1532
+ * ```
1533
+ *
1534
+ * @example
1535
+ *
1536
+ * ```tsx
1537
+ * type DivRef = React.ComponentRef<'div'>;
1538
+ * ```
1539
+ */
1540
+ type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1734
1541
  : never;
1735
1542
 
1736
1543
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
@@ -1831,6 +1638,11 @@ declare namespace React {
1831
1638
  * A {@link Dispatch} function can sometimes be called without any arguments.
1832
1639
  */
1833
1640
  type DispatchWithoutAction = () => void;
1641
+ // Limit the reducer to accept only 0 or 1 action arguments
1642
+ // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
1643
+ type AnyActionArg = [] | [any];
1644
+ // Get the dispatch type from the reducer arguments (captures optional action argument correctly)
1645
+ type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
1834
1646
  // Unlike redux, the actions _can_ be anything
1835
1647
  type Reducer<S, A> = (prevState: S, action: A) => S;
1836
1648
  // If useReducer accepts a reducer without action, dispatch may be called without any parameters.
@@ -1838,15 +1650,14 @@ declare namespace React {
1838
1650
  // types used to try and prevent the compiler from reducing S
1839
1651
  // to a supertype common with the second argument to useReducer()
1840
1652
  type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
1841
- type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
1842
- // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
1843
- type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> = R extends ReducerWithoutAction<infer S> ? S
1844
- : never;
1845
1653
  type DependencyList = readonly unknown[];
1846
1654
 
1847
1655
  // NOTE: callbacks are _only_ allowed to return either void, or a destructor.
1848
1656
  type EffectCallback = () => void | Destructor;
1849
1657
 
1658
+ /**
1659
+ * @deprecated Use `RefObject` instead.
1660
+ */
1850
1661
  interface MutableRefObject<T> {
1851
1662
  current: T;
1852
1663
  }
@@ -1885,12 +1696,10 @@ declare namespace React {
1885
1696
  * @version 16.8.0
1886
1697
  * @see {@link https://react.dev/reference/react/useReducer}
1887
1698
  */
1888
- // overload where dispatch could accept 0 arguments.
1889
- function useReducer<R extends ReducerWithoutAction<any>, I>(
1890
- reducer: R,
1891
- initializerArg: I,
1892
- initializer: (arg: I) => ReducerStateWithoutAction<R>,
1893
- ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
1699
+ function useReducer<S, A extends AnyActionArg>(
1700
+ reducer: (prevState: S, ...args: A) => S,
1701
+ initialState: S,
1702
+ ): [S, ActionDispatch<A>];
1894
1703
  /**
1895
1704
  * An alternative to `useState`.
1896
1705
  *
@@ -1901,71 +1710,11 @@ declare namespace React {
1901
1710
  * @version 16.8.0
1902
1711
  * @see {@link https://react.dev/reference/react/useReducer}
1903
1712
  */
1904
- // overload where dispatch could accept 0 arguments.
1905
- function useReducer<R extends ReducerWithoutAction<any>>(
1906
- reducer: R,
1907
- initializerArg: ReducerStateWithoutAction<R>,
1908
- initializer?: undefined,
1909
- ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
1910
- /**
1911
- * An alternative to `useState`.
1912
- *
1913
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1914
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1915
- * updates because you can pass `dispatch` down instead of callbacks.
1916
- *
1917
- * @version 16.8.0
1918
- * @see {@link https://react.dev/reference/react/useReducer}
1919
- */
1920
- // overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
1921
- // If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
1922
- // the last overload effectively behaves as if the identity function (x => x) is the initializer.
1923
- function useReducer<R extends Reducer<any, any>, I>(
1924
- reducer: R,
1925
- initializerArg: I & ReducerState<R>,
1926
- initializer: (arg: I & ReducerState<R>) => ReducerState<R>,
1927
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1928
- /**
1929
- * An alternative to `useState`.
1930
- *
1931
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1932
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1933
- * updates because you can pass `dispatch` down instead of callbacks.
1934
- *
1935
- * @version 16.8.0
1936
- * @see {@link https://react.dev/reference/react/useReducer}
1937
- */
1938
- // overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
1939
- function useReducer<R extends Reducer<any, any>, I>(
1940
- reducer: R,
1941
- initializerArg: I,
1942
- initializer: (arg: I) => ReducerState<R>,
1943
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1944
- /**
1945
- * An alternative to `useState`.
1946
- *
1947
- * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1948
- * multiple sub-values. It also lets you optimize performance for components that trigger deep
1949
- * updates because you can pass `dispatch` down instead of callbacks.
1950
- *
1951
- * @version 16.8.0
1952
- * @see {@link https://react.dev/reference/react/useReducer}
1953
- */
1954
-
1955
- // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.
1956
- // The Flow types do have an overload for 3-ary invocation with undefined initializer.
1957
-
1958
- // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common
1959
- // supertype between the reducer's return type and the initialState (or the initializer's return type),
1960
- // which would prevent autocompletion from ever working.
1961
-
1962
- // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
1963
- // in older versions, or a regression in newer versions of the typescript completion service.
1964
- function useReducer<R extends Reducer<any, any>>(
1965
- reducer: R,
1966
- initialState: ReducerState<R>,
1967
- initializer?: undefined,
1968
- ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1713
+ function useReducer<S, I, A extends AnyActionArg>(
1714
+ reducer: (prevState: S, ...args: A) => S,
1715
+ initialArg: I,
1716
+ init: (i: I) => S,
1717
+ ): [S, ActionDispatch<A>];
1969
1718
  /**
1970
1719
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1971
1720
  * (`initialValue`). The returned object will persist for the full lifetime of the component.
@@ -1976,7 +1725,7 @@ declare namespace React {
1976
1725
  * @version 16.8.0
1977
1726
  * @see {@link https://react.dev/reference/react/useRef}
1978
1727
  */
1979
- function useRef<T>(initialValue: T): MutableRefObject<T>;
1728
+ function useRef<T>(initialValue: T): RefObject<T>;
1980
1729
  // convenience overload for refs given as a ref prop as they typically start with a null value
1981
1730
  /**
1982
1731
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
@@ -1985,15 +1734,11 @@ declare namespace React {
1985
1734
  * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1986
1735
  * value around similar to how you’d use instance fields in classes.
1987
1736
  *
1988
- * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
1989
- * of the generic argument.
1990
- *
1991
1737
  * @version 16.8.0
1992
1738
  * @see {@link https://react.dev/reference/react/useRef}
1993
1739
  */
1994
- function useRef<T>(initialValue: T | null): RefObject<T>;
1995
- // convenience overload for potentially undefined initialValue / call with 0 arguments
1996
- // has a default to stop it from defaulting to {} instead
1740
+ function useRef<T>(initialValue: T | null): RefObject<T | null>;
1741
+ // convenience overload for undefined initialValue
1997
1742
  /**
1998
1743
  * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1999
1744
  * (`initialValue`). The returned object will persist for the full lifetime of the component.
@@ -2004,7 +1749,7 @@ declare namespace React {
2004
1749
  * @version 16.8.0
2005
1750
  * @see {@link https://react.dev/reference/react/useRef}
2006
1751
  */
2007
- function useRef<T = undefined>(): MutableRefObject<T | undefined>;
1752
+ function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
2008
1753
  /**
2009
1754
  * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
2010
1755
  * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
@@ -2051,7 +1796,7 @@ declare namespace React {
2051
1796
  */
2052
1797
  // A specific function type would not trigger implicit any.
2053
1798
  // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
2054
- // eslint-disable-next-line @typescript-eslint/ban-types
1799
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
2055
1800
  function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
2056
1801
  /**
2057
1802
  * `useMemo` will only recompute the memoized value when one of the `deps` has changed.
@@ -2074,8 +1819,7 @@ declare namespace React {
2074
1819
  // it's just the function name without the "use" prefix.
2075
1820
  function useDebugValue<T>(value: T, format?: (value: T) => any): void;
2076
1821
 
2077
- // must be synchronous
2078
- export type TransitionFunction = () => VoidOrUndefinedOnly;
1822
+ export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
2079
1823
  // strange definition to allow vscode to show documentation on the invocation
2080
1824
  export interface TransitionStartFunction {
2081
1825
  /**
@@ -2083,7 +1827,7 @@ declare namespace React {
2083
1827
  *
2084
1828
  * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
2085
1829
  *
2086
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
1830
+ * @param callback A function which causes state updates that can be deferred.
2087
1831
  */
2088
1832
  (callback: TransitionFunction): void;
2089
1833
  }
@@ -2097,10 +1841,11 @@ declare namespace React {
2097
1841
  * A good example of this is a text input.
2098
1842
  *
2099
1843
  * @param value The value that is going to be deferred
1844
+ * @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.
2100
1845
  *
2101
1846
  * @see {@link https://react.dev/reference/react/useDeferredValue}
2102
1847
  */
2103
- export function useDeferredValue<T>(value: T): T;
1848
+ export function useDeferredValue<T>(value: T, initialValue?: T): T;
2104
1849
 
2105
1850
  /**
2106
1851
  * Allows components to avoid undesirable loading states by waiting for content to load
@@ -2122,7 +1867,7 @@ declare namespace React {
2122
1867
  /**
2123
1868
  * Similar to `useTransition` but allows uses where hooks are not available.
2124
1869
  *
2125
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
1870
+ * @param callback A function which causes state updates that can be deferred.
2126
1871
  */
2127
1872
  export function startTransition(scope: TransitionFunction): void;
2128
1873
 
@@ -2137,6 +1882,11 @@ declare namespace React {
2137
1882
  *
2138
1883
  * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
2139
1884
  */
1885
+ // NOTES
1886
+ // - the order of these signatures matters - typescript will check the signatures in source order.
1887
+ // If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
1888
+ // `strictNullChecks: false`.
1889
+ // - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
2140
1890
  // 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.
2141
1891
  export function act(callback: () => VoidOrUndefinedOnly): void;
2142
1892
  export function act<T>(callback: () => T | Promise<T>): Promise<T>;
@@ -2164,6 +1914,39 @@ declare namespace React {
2164
1914
  getServerSnapshot?: () => Snapshot,
2165
1915
  ): Snapshot;
2166
1916
 
1917
+ export function useOptimistic<State>(
1918
+ passthrough: State,
1919
+ ): [State, (action: State | ((pendingState: State) => State)) => void];
1920
+ export function useOptimistic<State, Action>(
1921
+ passthrough: State,
1922
+ reducer: (state: State, action: Action) => State,
1923
+ ): [State, (action: Action) => void];
1924
+
1925
+ export type Usable<T> = PromiseLike<T> | Context<T>;
1926
+
1927
+ export function use<T>(usable: Usable<T>): T;
1928
+
1929
+ export function useActionState<State>(
1930
+ action: (state: Awaited<State>) => State | Promise<State>,
1931
+ initialState: Awaited<State>,
1932
+ permalink?: string,
1933
+ ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
1934
+ export function useActionState<State, Payload>(
1935
+ action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
1936
+ initialState: Awaited<State>,
1937
+ permalink?: string,
1938
+ ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1939
+
1940
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1941
+ export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
1942
+
1943
+ /**
1944
+ * Warning: Only available in development builds.
1945
+ *
1946
+ * @see {@link https://react.dev/reference/react/captureOwnerStack Reference docs}
1947
+ */
1948
+ function captureOwnerStack(): string | null;
1949
+
2167
1950
  //
2168
1951
  // Event System
2169
1952
  // ----------------------------------------------------------------------
@@ -2236,6 +2019,10 @@ declare namespace React {
2236
2019
  target: EventTarget & T;
2237
2020
  }
2238
2021
 
2022
+ interface InputEvent<T = Element> extends SyntheticEvent<T, NativeInputEvent> {
2023
+ data: string;
2024
+ }
2025
+
2239
2026
  export type ModifierKey =
2240
2027
  | "Alt"
2241
2028
  | "AltGraph"
@@ -2331,6 +2118,11 @@ declare namespace React {
2331
2118
  pseudoElement: string;
2332
2119
  }
2333
2120
 
2121
+ interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
2122
+ oldState: "closed" | "open";
2123
+ newState: "closed" | "open";
2124
+ }
2125
+
2334
2126
  interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
2335
2127
  elapsedTime: number;
2336
2128
  propertyName: string;
@@ -2351,6 +2143,7 @@ declare namespace React {
2351
2143
  type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
2352
2144
  type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
2353
2145
  type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
2146
+ type InputEventHandler<T = Element> = EventHandler<InputEvent<T>>;
2354
2147
  type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
2355
2148
  type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
2356
2149
  type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
@@ -2358,6 +2151,7 @@ declare namespace React {
2358
2151
  type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
2359
2152
  type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
2360
2153
  type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
2154
+ type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
2361
2155
  type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
2362
2156
 
2363
2157
  //
@@ -2408,7 +2202,7 @@ declare namespace React {
2408
2202
  // Form Events
2409
2203
  onChange?: FormEventHandler<T> | undefined;
2410
2204
  onChangeCapture?: FormEventHandler<T> | undefined;
2411
- onBeforeInput?: FormEventHandler<T> | undefined;
2205
+ onBeforeInput?: InputEventHandler<T> | undefined;
2412
2206
  onBeforeInputCapture?: FormEventHandler<T> | undefined;
2413
2207
  onInput?: FormEventHandler<T> | undefined;
2414
2208
  onInputCapture?: FormEventHandler<T> | undefined;
@@ -2428,9 +2222,9 @@ declare namespace React {
2428
2222
  // Keyboard Events
2429
2223
  onKeyDown?: KeyboardEventHandler<T> | undefined;
2430
2224
  onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
2431
- /** @deprecated */
2225
+ /** @deprecated Use `onKeyUp` or `onKeyDown` instead */
2432
2226
  onKeyPress?: KeyboardEventHandler<T> | undefined;
2433
- /** @deprecated */
2227
+ /** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
2434
2228
  onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
2435
2229
  onKeyUp?: KeyboardEventHandler<T> | undefined;
2436
2230
  onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
@@ -2466,8 +2260,6 @@ declare namespace React {
2466
2260
  onProgressCapture?: ReactEventHandler<T> | undefined;
2467
2261
  onRateChange?: ReactEventHandler<T> | undefined;
2468
2262
  onRateChangeCapture?: ReactEventHandler<T> | undefined;
2469
- onResize?: ReactEventHandler<T> | undefined;
2470
- onResizeCapture?: ReactEventHandler<T> | undefined;
2471
2263
  onSeeked?: ReactEventHandler<T> | undefined;
2472
2264
  onSeekedCapture?: ReactEventHandler<T> | undefined;
2473
2265
  onSeeking?: ReactEventHandler<T> | undefined;
@@ -2558,6 +2350,8 @@ declare namespace React {
2558
2350
  // UI Events
2559
2351
  onScroll?: UIEventHandler<T> | undefined;
2560
2352
  onScrollCapture?: UIEventHandler<T> | undefined;
2353
+ onScrollEnd?: UIEventHandler<T> | undefined;
2354
+ onScrollEndCapture?: UIEventHandler<T> | undefined;
2561
2355
 
2562
2356
  // Wheel Events
2563
2357
  onWheel?: WheelEventHandler<T> | undefined;
@@ -2571,9 +2365,19 @@ declare namespace React {
2571
2365
  onAnimationIteration?: AnimationEventHandler<T> | undefined;
2572
2366
  onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
2573
2367
 
2368
+ // Toggle Events
2369
+ onToggle?: ToggleEventHandler<T> | undefined;
2370
+ onBeforeToggle?: ToggleEventHandler<T> | undefined;
2371
+
2574
2372
  // Transition Events
2373
+ onTransitionCancel?: TransitionEventHandler<T> | undefined;
2374
+ onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
2575
2375
  onTransitionEnd?: TransitionEventHandler<T> | undefined;
2576
2376
  onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
2377
+ onTransitionRun?: TransitionEventHandler<T> | undefined;
2378
+ onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
2379
+ onTransitionStart?: TransitionEventHandler<T> | undefined;
2380
+ onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
2577
2381
  }
2578
2382
 
2579
2383
  export interface CSSProperties extends CSS.Properties<string | number> {
@@ -2893,12 +2697,14 @@ declare namespace React {
2893
2697
 
2894
2698
  // Standard HTML Attributes
2895
2699
  accessKey?: string | undefined;
2700
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
2896
2701
  autoFocus?: boolean | undefined;
2897
2702
  className?: string | undefined;
2898
2703
  contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
2899
2704
  contextMenu?: string | undefined;
2900
2705
  dir?: string | undefined;
2901
2706
  draggable?: Booleanish | undefined;
2707
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
2902
2708
  hidden?: boolean | undefined;
2903
2709
  id?: string | undefined;
2904
2710
  lang?: string | undefined;
@@ -2930,7 +2736,6 @@ declare namespace React {
2930
2736
  vocab?: string | undefined;
2931
2737
 
2932
2738
  // Non-standard Attributes
2933
- autoCapitalize?: string | undefined;
2934
2739
  autoCorrect?: string | undefined;
2935
2740
  autoSave?: string | undefined;
2936
2741
  color?: string | undefined;
@@ -2943,7 +2748,16 @@ declare namespace React {
2943
2748
  security?: string | undefined;
2944
2749
  unselectable?: "on" | "off" | undefined;
2945
2750
 
2751
+ // Popover API
2752
+ popover?: "" | "auto" | "manual" | undefined;
2753
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
2754
+ popoverTarget?: string | undefined;
2755
+
2946
2756
  // Living Standard
2757
+ /**
2758
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
2759
+ */
2760
+ inert?: boolean | undefined;
2947
2761
  /**
2948
2762
  * Hints at the type of data that might be entered by the user while editing the element or its contents
2949
2763
  * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
@@ -2954,6 +2768,14 @@ declare namespace React {
2954
2768
  * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
2955
2769
  */
2956
2770
  is?: string | undefined;
2771
+ /**
2772
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts}
2773
+ */
2774
+ exportparts?: string | undefined;
2775
+ /**
2776
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part}
2777
+ */
2778
+ part?: string | undefined;
2957
2779
  }
2958
2780
 
2959
2781
  /**
@@ -2970,6 +2792,7 @@ declare namespace React {
2970
2792
  action?:
2971
2793
  | string
2972
2794
  | undefined
2795
+ | ((formData: FormData) => void | Promise<void>)
2973
2796
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2974
2797
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2975
2798
  ];
@@ -3004,6 +2827,7 @@ declare namespace React {
3004
2827
  formAction?:
3005
2828
  | string
3006
2829
  | undefined
2830
+ | ((formData: FormData) => void | Promise<void>)
3007
2831
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3008
2832
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3009
2833
  ];
@@ -3136,6 +2960,7 @@ declare namespace React {
3136
2960
  form?: string | undefined;
3137
2961
  formAction?:
3138
2962
  | string
2963
+ | ((formData: FormData) => void | Promise<void>)
3139
2964
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3140
2965
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3141
2966
  ]
@@ -3169,7 +2994,6 @@ declare namespace React {
3169
2994
 
3170
2995
  interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
3171
2996
  open?: boolean | undefined;
3172
- onToggle?: ReactEventHandler<T> | undefined;
3173
2997
  name?: string | undefined;
3174
2998
  }
3175
2999
 
@@ -3202,6 +3026,7 @@ declare namespace React {
3202
3026
  action?:
3203
3027
  | string
3204
3028
  | undefined
3029
+ | ((formData: FormData) => void | Promise<void>)
3205
3030
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3206
3031
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3207
3032
  ];
@@ -3240,6 +3065,8 @@ declare namespace React {
3240
3065
  width?: number | string | undefined;
3241
3066
  }
3242
3067
 
3068
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {}
3069
+
3243
3070
  interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
3244
3071
  alt?: string | undefined;
3245
3072
  crossOrigin?: CrossOrigin;
@@ -3249,7 +3076,12 @@ declare namespace React {
3249
3076
  loading?: "eager" | "lazy" | undefined;
3250
3077
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3251
3078
  sizes?: string | undefined;
3252
- src?: string | undefined;
3079
+ src?:
3080
+ | string
3081
+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES[
3082
+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES
3083
+ ]
3084
+ | undefined;
3253
3085
  srcSet?: string | undefined;
3254
3086
  useMap?: string | undefined;
3255
3087
  width?: number | string | undefined;
@@ -3354,10 +3186,10 @@ declare namespace React {
3354
3186
  capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3355
3187
  checked?: boolean | undefined;
3356
3188
  disabled?: boolean | undefined;
3357
- enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
3358
3189
  form?: string | undefined;
3359
3190
  formAction?:
3360
3191
  | string
3192
+ | ((formData: FormData) => void | Promise<void>)
3361
3193
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3362
3194
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3363
3195
  ]
@@ -3408,6 +3240,7 @@ declare namespace React {
3408
3240
 
3409
3241
  interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
3410
3242
  as?: string | undefined;
3243
+ blocking?: "render" | (string & {}) | undefined;
3411
3244
  crossOrigin?: CrossOrigin;
3412
3245
  fetchPriority?: "high" | "low" | "auto";
3413
3246
  href?: string | undefined;
@@ -3420,6 +3253,9 @@ declare namespace React {
3420
3253
  sizes?: string | undefined;
3421
3254
  type?: string | undefined;
3422
3255
  charSet?: string | undefined;
3256
+
3257
+ // React props
3258
+ precedence?: string | undefined;
3423
3259
  }
3424
3260
 
3425
3261
  interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3430,6 +3266,8 @@ declare namespace React {
3430
3266
  type?: string | undefined;
3431
3267
  }
3432
3268
 
3269
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {}
3270
+
3433
3271
  interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
3434
3272
  autoPlay?: boolean | undefined;
3435
3273
  controls?: boolean | undefined;
@@ -3440,7 +3278,12 @@ declare namespace React {
3440
3278
  muted?: boolean | undefined;
3441
3279
  playsInline?: boolean | undefined;
3442
3280
  preload?: string | undefined;
3443
- src?: string | undefined;
3281
+ src?:
3282
+ | string
3283
+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES[
3284
+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES
3285
+ ]
3286
+ | undefined;
3444
3287
  }
3445
3288
 
3446
3289
  interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3517,6 +3360,7 @@ declare namespace React {
3517
3360
 
3518
3361
  interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
3519
3362
  async?: boolean | undefined;
3363
+ blocking?: "render" | (string & {}) | undefined;
3520
3364
  /** @deprecated */
3521
3365
  charSet?: string | undefined;
3522
3366
  crossOrigin?: CrossOrigin;
@@ -3551,9 +3395,14 @@ declare namespace React {
3551
3395
  }
3552
3396
 
3553
3397
  interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
3398
+ blocking?: "render" | (string & {}) | undefined;
3554
3399
  media?: string | undefined;
3555
3400
  scoped?: boolean | undefined;
3556
3401
  type?: string | undefined;
3402
+
3403
+ // React props
3404
+ href?: string | undefined;
3405
+ precedence?: string | undefined;
3557
3406
  }
3558
3407
 
3559
3408
  interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -3627,6 +3476,9 @@ declare namespace React {
3627
3476
  width?: number | string | undefined;
3628
3477
  disablePictureInPicture?: boolean | undefined;
3629
3478
  disableRemotePlayback?: boolean | undefined;
3479
+
3480
+ onResize?: ReactEventHandler<T> | undefined;
3481
+ onResizeCapture?: ReactEventHandler<T> | undefined;
3630
3482
  }
3631
3483
 
3632
3484
  // this list is "complete" in that it contains every SVG attribute
@@ -3941,259 +3793,184 @@ declare namespace React {
3941
3793
  webpreferences?: string | undefined;
3942
3794
  }
3943
3795
 
3944
- //
3945
- // React.DOM
3946
- // ----------------------------------------------------------------------
3947
-
3948
- interface ReactHTML {
3949
- a: DetailedHTMLFactory<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
3950
- abbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3951
- address: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3952
- area: DetailedHTMLFactory<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
3953
- article: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3954
- aside: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3955
- audio: DetailedHTMLFactory<AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
3956
- b: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3957
- base: DetailedHTMLFactory<BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
3958
- bdi: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3959
- bdo: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3960
- big: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3961
- blockquote: DetailedHTMLFactory<BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
3962
- body: DetailedHTMLFactory<HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
3963
- br: DetailedHTMLFactory<HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
3964
- button: DetailedHTMLFactory<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
3965
- canvas: DetailedHTMLFactory<CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
3966
- caption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3967
- center: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3968
- cite: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3969
- code: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3970
- col: DetailedHTMLFactory<ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3971
- colgroup: DetailedHTMLFactory<ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3972
- data: DetailedHTMLFactory<DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
3973
- datalist: DetailedHTMLFactory<HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
3974
- dd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3975
- del: DetailedHTMLFactory<DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
3976
- details: DetailedHTMLFactory<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
3977
- dfn: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3978
- dialog: DetailedHTMLFactory<DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
3979
- div: DetailedHTMLFactory<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
3980
- dl: DetailedHTMLFactory<HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
3981
- dt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3982
- em: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3983
- embed: DetailedHTMLFactory<EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
3984
- fieldset: DetailedHTMLFactory<FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
3985
- figcaption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3986
- figure: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3987
- footer: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3988
- form: DetailedHTMLFactory<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
3989
- h1: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3990
- h2: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3991
- h3: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3992
- h4: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3993
- h5: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3994
- h6: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3995
- head: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLHeadElement>;
3996
- header: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3997
- hgroup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
3998
- hr: DetailedHTMLFactory<HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
3999
- html: DetailedHTMLFactory<HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
4000
- i: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4001
- iframe: DetailedHTMLFactory<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
4002
- img: DetailedHTMLFactory<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
4003
- input: DetailedHTMLFactory<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4004
- ins: DetailedHTMLFactory<InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
4005
- kbd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4006
- keygen: DetailedHTMLFactory<KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
4007
- label: DetailedHTMLFactory<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
4008
- legend: DetailedHTMLFactory<HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
4009
- li: DetailedHTMLFactory<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
4010
- link: DetailedHTMLFactory<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
4011
- main: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4012
- map: DetailedHTMLFactory<MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
4013
- mark: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4014
- menu: DetailedHTMLFactory<MenuHTMLAttributes<HTMLElement>, HTMLElement>;
4015
- menuitem: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4016
- meta: DetailedHTMLFactory<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
4017
- meter: DetailedHTMLFactory<MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
4018
- nav: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4019
- noscript: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4020
- object: DetailedHTMLFactory<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
4021
- ol: DetailedHTMLFactory<OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
4022
- optgroup: DetailedHTMLFactory<OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
4023
- option: DetailedHTMLFactory<OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
4024
- output: DetailedHTMLFactory<OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
4025
- p: DetailedHTMLFactory<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
4026
- param: DetailedHTMLFactory<ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
4027
- picture: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4028
- pre: DetailedHTMLFactory<HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
4029
- progress: DetailedHTMLFactory<ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
4030
- q: DetailedHTMLFactory<QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4031
- rp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4032
- rt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4033
- ruby: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4034
- s: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4035
- samp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4036
- search: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4037
- slot: DetailedHTMLFactory<SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
4038
- script: DetailedHTMLFactory<ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
4039
- section: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4040
- select: DetailedHTMLFactory<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
4041
- small: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4042
- source: DetailedHTMLFactory<SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
4043
- span: DetailedHTMLFactory<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
4044
- strong: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4045
- style: DetailedHTMLFactory<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
4046
- sub: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4047
- summary: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4048
- sup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4049
- table: DetailedHTMLFactory<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
4050
- template: DetailedHTMLFactory<HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
4051
- tbody: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4052
- td: DetailedHTMLFactory<TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
4053
- textarea: DetailedHTMLFactory<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
4054
- tfoot: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4055
- th: DetailedHTMLFactory<ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
4056
- thead: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4057
- time: DetailedHTMLFactory<TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
4058
- title: DetailedHTMLFactory<HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
4059
- tr: DetailedHTMLFactory<HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
4060
- track: DetailedHTMLFactory<TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
4061
- u: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4062
- ul: DetailedHTMLFactory<HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
4063
- "var": DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4064
- video: DetailedHTMLFactory<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
4065
- wbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
4066
- webview: DetailedHTMLFactory<WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
4067
- }
4068
-
4069
- interface ReactSVG {
4070
- animate: SVGFactory;
4071
- circle: SVGFactory;
4072
- clipPath: SVGFactory;
4073
- defs: SVGFactory;
4074
- desc: SVGFactory;
4075
- ellipse: SVGFactory;
4076
- feBlend: SVGFactory;
4077
- feColorMatrix: SVGFactory;
4078
- feComponentTransfer: SVGFactory;
4079
- feComposite: SVGFactory;
4080
- feConvolveMatrix: SVGFactory;
4081
- feDiffuseLighting: SVGFactory;
4082
- feDisplacementMap: SVGFactory;
4083
- feDistantLight: SVGFactory;
4084
- feDropShadow: SVGFactory;
4085
- feFlood: SVGFactory;
4086
- feFuncA: SVGFactory;
4087
- feFuncB: SVGFactory;
4088
- feFuncG: SVGFactory;
4089
- feFuncR: SVGFactory;
4090
- feGaussianBlur: SVGFactory;
4091
- feImage: SVGFactory;
4092
- feMerge: SVGFactory;
4093
- feMergeNode: SVGFactory;
4094
- feMorphology: SVGFactory;
4095
- feOffset: SVGFactory;
4096
- fePointLight: SVGFactory;
4097
- feSpecularLighting: SVGFactory;
4098
- feSpotLight: SVGFactory;
4099
- feTile: SVGFactory;
4100
- feTurbulence: SVGFactory;
4101
- filter: SVGFactory;
4102
- foreignObject: SVGFactory;
4103
- g: SVGFactory;
4104
- image: SVGFactory;
4105
- line: SVGFactory;
4106
- linearGradient: SVGFactory;
4107
- marker: SVGFactory;
4108
- mask: SVGFactory;
4109
- metadata: SVGFactory;
4110
- path: SVGFactory;
4111
- pattern: SVGFactory;
4112
- polygon: SVGFactory;
4113
- polyline: SVGFactory;
4114
- radialGradient: SVGFactory;
4115
- rect: SVGFactory;
4116
- stop: SVGFactory;
4117
- svg: SVGFactory;
4118
- switch: SVGFactory;
4119
- symbol: SVGFactory;
4120
- text: SVGFactory;
4121
- textPath: SVGFactory;
4122
- tspan: SVGFactory;
4123
- use: SVGFactory;
4124
- view: SVGFactory;
4125
- }
4126
-
4127
- interface ReactDOM extends ReactHTML, ReactSVG {}
4128
-
4129
- //
4130
- // React.PropTypes
4131
- // ----------------------------------------------------------------------
4132
-
4133
- /**
4134
- * @deprecated Use `Validator` from the ´prop-types` instead.
4135
- */
4136
- type Validator<T> = PropTypes.Validator<T>;
4137
-
4138
- /**
4139
- * @deprecated Use `Requireable` from the ´prop-types` instead.
4140
- */
4141
- type Requireable<T> = PropTypes.Requireable<T>;
4142
-
4143
- /**
4144
- * @deprecated Use `ValidationMap` from the ´prop-types` instead.
4145
- */
4146
- type ValidationMap<T> = PropTypes.ValidationMap<T>;
4147
-
4148
- /**
4149
- * @deprecated Use `WeakValidationMap` from the ´prop-types` instead.
4150
- */
4151
- type WeakValidationMap<T> = {
4152
- [K in keyof T]?: null extends T[K] ? Validator<T[K] | null | undefined>
4153
- : undefined extends T[K] ? Validator<T[K] | null | undefined>
4154
- : Validator<T[K]>;
4155
- };
4156
-
4157
- /**
4158
- * @deprecated Use `PropTypes.*` where `PropTypes` comes from `import * as PropTypes from 'prop-types'` instead.
4159
- */
4160
- interface ReactPropTypes {
4161
- any: typeof PropTypes.any;
4162
- array: typeof PropTypes.array;
4163
- bool: typeof PropTypes.bool;
4164
- func: typeof PropTypes.func;
4165
- number: typeof PropTypes.number;
4166
- object: typeof PropTypes.object;
4167
- string: typeof PropTypes.string;
4168
- node: typeof PropTypes.node;
4169
- element: typeof PropTypes.element;
4170
- instanceOf: typeof PropTypes.instanceOf;
4171
- oneOf: typeof PropTypes.oneOf;
4172
- oneOfType: typeof PropTypes.oneOfType;
4173
- arrayOf: typeof PropTypes.arrayOf;
4174
- objectOf: typeof PropTypes.objectOf;
4175
- shape: typeof PropTypes.shape;
4176
- exact: typeof PropTypes.exact;
4177
- }
4178
-
4179
- //
4180
- // React.Children
4181
- // ----------------------------------------------------------------------
4182
-
4183
- /**
4184
- * @deprecated - Use `typeof React.Children` instead.
4185
- */
4186
- // Sync with type of `const Children`.
4187
- interface ReactChildren {
4188
- map<T, C>(
4189
- children: C | readonly C[],
4190
- fn: (child: C, index: number) => T,
4191
- ): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
4192
- forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
4193
- count(children: any): number;
4194
- only<C>(children: C): C extends any[] ? never : C;
4195
- toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
4196
- }
3796
+ // TODO: Move to react-dom
3797
+ type HTMLElementType =
3798
+ | "a"
3799
+ | "abbr"
3800
+ | "address"
3801
+ | "area"
3802
+ | "article"
3803
+ | "aside"
3804
+ | "audio"
3805
+ | "b"
3806
+ | "base"
3807
+ | "bdi"
3808
+ | "bdo"
3809
+ | "big"
3810
+ | "blockquote"
3811
+ | "body"
3812
+ | "br"
3813
+ | "button"
3814
+ | "canvas"
3815
+ | "caption"
3816
+ | "center"
3817
+ | "cite"
3818
+ | "code"
3819
+ | "col"
3820
+ | "colgroup"
3821
+ | "data"
3822
+ | "datalist"
3823
+ | "dd"
3824
+ | "del"
3825
+ | "details"
3826
+ | "dfn"
3827
+ | "dialog"
3828
+ | "div"
3829
+ | "dl"
3830
+ | "dt"
3831
+ | "em"
3832
+ | "embed"
3833
+ | "fieldset"
3834
+ | "figcaption"
3835
+ | "figure"
3836
+ | "footer"
3837
+ | "form"
3838
+ | "h1"
3839
+ | "h2"
3840
+ | "h3"
3841
+ | "h4"
3842
+ | "h5"
3843
+ | "h6"
3844
+ | "head"
3845
+ | "header"
3846
+ | "hgroup"
3847
+ | "hr"
3848
+ | "html"
3849
+ | "i"
3850
+ | "iframe"
3851
+ | "img"
3852
+ | "input"
3853
+ | "ins"
3854
+ | "kbd"
3855
+ | "keygen"
3856
+ | "label"
3857
+ | "legend"
3858
+ | "li"
3859
+ | "link"
3860
+ | "main"
3861
+ | "map"
3862
+ | "mark"
3863
+ | "menu"
3864
+ | "menuitem"
3865
+ | "meta"
3866
+ | "meter"
3867
+ | "nav"
3868
+ | "noscript"
3869
+ | "object"
3870
+ | "ol"
3871
+ | "optgroup"
3872
+ | "option"
3873
+ | "output"
3874
+ | "p"
3875
+ | "param"
3876
+ | "picture"
3877
+ | "pre"
3878
+ | "progress"
3879
+ | "q"
3880
+ | "rp"
3881
+ | "rt"
3882
+ | "ruby"
3883
+ | "s"
3884
+ | "samp"
3885
+ | "search"
3886
+ | "slot"
3887
+ | "script"
3888
+ | "section"
3889
+ | "select"
3890
+ | "small"
3891
+ | "source"
3892
+ | "span"
3893
+ | "strong"
3894
+ | "style"
3895
+ | "sub"
3896
+ | "summary"
3897
+ | "sup"
3898
+ | "table"
3899
+ | "template"
3900
+ | "tbody"
3901
+ | "td"
3902
+ | "textarea"
3903
+ | "tfoot"
3904
+ | "th"
3905
+ | "thead"
3906
+ | "time"
3907
+ | "title"
3908
+ | "tr"
3909
+ | "track"
3910
+ | "u"
3911
+ | "ul"
3912
+ | "var"
3913
+ | "video"
3914
+ | "wbr"
3915
+ | "webview";
3916
+
3917
+ // TODO: Move to react-dom
3918
+ type SVGElementType =
3919
+ | "animate"
3920
+ | "circle"
3921
+ | "clipPath"
3922
+ | "defs"
3923
+ | "desc"
3924
+ | "ellipse"
3925
+ | "feBlend"
3926
+ | "feColorMatrix"
3927
+ | "feComponentTransfer"
3928
+ | "feComposite"
3929
+ | "feConvolveMatrix"
3930
+ | "feDiffuseLighting"
3931
+ | "feDisplacementMap"
3932
+ | "feDistantLight"
3933
+ | "feDropShadow"
3934
+ | "feFlood"
3935
+ | "feFuncA"
3936
+ | "feFuncB"
3937
+ | "feFuncG"
3938
+ | "feFuncR"
3939
+ | "feGaussianBlur"
3940
+ | "feImage"
3941
+ | "feMerge"
3942
+ | "feMergeNode"
3943
+ | "feMorphology"
3944
+ | "feOffset"
3945
+ | "fePointLight"
3946
+ | "feSpecularLighting"
3947
+ | "feSpotLight"
3948
+ | "feTile"
3949
+ | "feTurbulence"
3950
+ | "filter"
3951
+ | "foreignObject"
3952
+ | "g"
3953
+ | "image"
3954
+ | "line"
3955
+ | "linearGradient"
3956
+ | "marker"
3957
+ | "mask"
3958
+ | "metadata"
3959
+ | "path"
3960
+ | "pattern"
3961
+ | "polygon"
3962
+ | "polyline"
3963
+ | "radialGradient"
3964
+ | "rect"
3965
+ | "stop"
3966
+ | "svg"
3967
+ | "switch"
3968
+ | "symbol"
3969
+ | "text"
3970
+ | "textPath"
3971
+ | "tspan"
3972
+ | "use"
3973
+ | "view";
4197
3974
 
4198
3975
  //
4199
3976
  // Browser Interfaces
@@ -4235,68 +4012,6 @@ declare namespace React {
4235
4012
  }
4236
4013
 
4237
4014
  // Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
4238
- namespace JSX {
4239
- type ElementType = GlobalJSXElementType;
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
4015
  namespace JSX {
4301
4016
  // We don't just alias React.ElementType because React.ElementType
4302
4017
  // historically does more than we need it to.
@@ -4520,18 +4235,18 @@ declare global {
4520
4235
  }
4521
4236
  }
4522
4237
 
4523
- // React.JSX needs to point to global.JSX to keep global module augmentations intact.
4524
- // But we can't access global.JSX so we need to create these aliases instead.
4525
- // Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
4526
- type GlobalJSXElementType = JSX.ElementType;
4527
- interface GlobalJSXElement extends JSX.Element {}
4528
- interface GlobalJSXElementClass extends JSX.ElementClass {}
4529
- interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
4530
- interface GlobalJSXElementChildrenAttribute extends JSX.ElementChildrenAttribute {}
4531
-
4532
- type GlobalJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>;
4238
+ type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4533
4239
 
4534
- interface GlobalJSXIntrinsicAttributes extends JSX.IntrinsicAttributes {}
4535
- interface GlobalJSXIntrinsicClassAttributes<T> extends JSX.IntrinsicClassAttributes<T> {}
4240
+ // Any prop that has a default prop becomes optional, but its type is unchanged
4241
+ // Undeclared default props are augmented into the resulting allowable attributes
4242
+ // If declared props have indexed properties, ignore default props entirely as keyof gets widened
4243
+ // Wrap in an outer-level conditional type to allow distribution over props that are unions
4244
+ type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4245
+ :
4246
+ & Pick<P, Exclude<keyof P, keyof D>>
4247
+ & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4248
+ & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4249
+ : never;
4536
4250
 
4537
- interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}
4251
+ type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
4252
+ : P;