@types/react 18.2.55 → 18.2.65

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/README.md CHANGED
@@ -8,8 +8,8 @@ This package contains type definitions for react (https://react.dev/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 06 Feb 2024 09:35:42 GMT
11
+ * Last updated: Tue, 12 Mar 2024 00:22:44 GMT
12
12
  * Dependencies: [@types/prop-types](https://npmjs.com/package/@types/prop-types), [@types/scheduler](https://npmjs.com/package/@types/scheduler), [csstype](https://npmjs.com/package/csstype)
13
13
 
14
14
  # Credits
15
- These definitions were written by [Asana](https://asana.com), [AssureSign](http://www.assuresign.com), [Microsoft](https://microsoft.com), [John Reilly](https://github.com/johnnyreilly), [Benoit Benezech](https://github.com/bbenezech), [Patricio Zavolinsky](https://github.com/pzavolinsky), [Eric Anderson](https://github.com/ericanderson), [Dovydas Navickas](https://github.com/DovydasNavickas), [Josh Rutherford](https://github.com/theruther4d), [Guilherme Hübner](https://github.com/guilhermehubner), [Ferdy Budhidharma](https://github.com/ferdaber), [Johann Rakotoharisoa](https://github.com/jrakotoharisoa), [Olivier Pascal](https://github.com/pascaloliv), [Martin Hochel](https://github.com/hotell), [Frank Li](https://github.com/franklixuefei), [Jessica Franco](https://github.com/Jessidhia), [Saransh Kataria](https://github.com/saranshkataria), [Kanitkorn Sujautra](https://github.com/lukyth), [Sebastian Silbermann](https://github.com/eps1lon), [Kyle Scully](https://github.com/zieka), [Cong Zhang](https://github.com/dancerphil), [Dimitri Mitropoulos](https://github.com/dimitropoulos), [JongChan Choi](https://github.com/disjukr), [Victor Magalhães](https://github.com/vhfmag), [Dale Tan](https://github.com/hellatan), [Priyanshu Rav](https://github.com/priyanshurav), and [Dmitry Semigradsky](https://github.com/Semigradsky).
15
+ These definitions were written by [Asana](https://asana.com), [AssureSign](http://www.assuresign.com), [Microsoft](https://microsoft.com), [John Reilly](https://github.com/johnnyreilly), [Benoit Benezech](https://github.com/bbenezech), [Patricio Zavolinsky](https://github.com/pzavolinsky), [Eric Anderson](https://github.com/ericanderson), [Dovydas Navickas](https://github.com/DovydasNavickas), [Josh Rutherford](https://github.com/theruther4d), [Guilherme Hübner](https://github.com/guilhermehubner), [Ferdy Budhidharma](https://github.com/ferdaber), [Johann Rakotoharisoa](https://github.com/jrakotoharisoa), [Olivier Pascal](https://github.com/pascaloliv), [Martin Hochel](https://github.com/hotell), [Frank Li](https://github.com/franklixuefei), [Jessica Franco](https://github.com/Jessidhia), [Saransh Kataria](https://github.com/saranshkataria), [Kanitkorn Sujautra](https://github.com/lukyth), [Sebastian Silbermann](https://github.com/eps1lon), [Kyle Scully](https://github.com/zieka), [Cong Zhang](https://github.com/dancerphil), [Dimitri Mitropoulos](https://github.com/dimitropoulos), [JongChan Choi](https://github.com/disjukr), [Victor Magalhães](https://github.com/vhfmag), [Dale Tan](https://github.com/hellatan), [Priyanshu Rav](https://github.com/priyanshurav), [Dmitry Semigradsky](https://github.com/Semigradsky), and [Matt Pocock](https://github.com/mattpocock).
react/experimental.d.ts CHANGED
@@ -42,10 +42,22 @@ declare const UNDEFINED_VOID_ONLY: unique symbol;
42
42
  type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
43
43
 
44
44
  declare module "." {
45
- // Need an interface to not cause ReactNode to be a self-referential type.
46
- interface PromiseLikeOfReactNode extends PromiseLike<ReactNode> {}
45
+ /**
46
+ * @internal Use `Awaited<ReactNode>` instead
47
+ */
48
+ // Helper type to enable `Awaited<ReactNode>`.
49
+ // Must be a copy of the non-thenables of `ReactNode`.
50
+ type AwaitedReactNode =
51
+ | ReactElement
52
+ | string
53
+ | number
54
+ | Iterable<AwaitedReactNode>
55
+ | ReactPortal
56
+ | boolean
57
+ | null
58
+ | undefined;
47
59
  interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {
48
- promises: PromiseLikeOfReactNode;
60
+ promises: Promise<AwaitedReactNode>;
49
61
  }
50
62
 
51
63
  export interface SuspenseProps {
react/global.d.ts CHANGED
@@ -140,6 +140,7 @@ interface SVGPolygonElement extends SVGElement {}
140
140
  interface SVGPolylineElement extends SVGElement {}
141
141
  interface SVGRadialGradientElement extends SVGElement {}
142
142
  interface SVGRectElement extends SVGElement {}
143
+ interface SVGSetElement extends SVGElement {}
143
144
  interface SVGStopElement extends SVGElement {}
144
145
  interface SVGSwitchElement extends SVGElement {}
145
146
  interface SVGSymbolElement extends SVGElement {}
react/index.d.ts CHANGED
@@ -189,6 +189,7 @@ declare namespace React {
189
189
  * <div ref="myRef" />
190
190
  * ```
191
191
  */
192
+ // TODO: Remove the string ref special case from `PropsWithRef` once we remove LegacyRef
192
193
  type LegacyRef<T> = string | Ref<T>;
193
194
 
194
195
  /**
@@ -217,9 +218,10 @@ declare namespace React {
217
218
  > =
218
219
  // need to check first if `ref` is a valid prop for ts@3.0
219
220
  // otherwise it will infer `{}` instead of `never`
220
- "ref" extends keyof ComponentPropsWithRef<C> ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends Ref<
221
+ "ref" extends keyof ComponentPropsWithRef<C>
222
+ ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends RefAttributes<
221
223
  infer Instance
222
- > ? Instance
224
+ >["ref"] ? Instance
223
225
  : never
224
226
  : never;
225
227
 
@@ -232,9 +234,55 @@ declare namespace React {
232
234
  */
233
235
  type Key = string | number | bigint;
234
236
 
237
+ /**
238
+ * @internal The props any component can receive.
239
+ * You don't have to add this type. All components automatically accept these props.
240
+ * ```tsx
241
+ * const Component = () => <div />;
242
+ * <Component key="one" />
243
+ * ```
244
+ *
245
+ * WARNING: The implementation of a component will never have access to these attributes.
246
+ * The following example would be incorrect usage because {@link Component} would never have access to `key`:
247
+ * ```tsx
248
+ * const Component = (props: React.Attributes) => props.key;
249
+ * ```
250
+ */
235
251
  interface Attributes {
236
252
  key?: Key | null | undefined;
237
253
  }
254
+ /**
255
+ * The props any component accepting refs can receive.
256
+ * Class components, built-in browser components (e.g. `div`) and forwardRef components can receive refs and automatically accept these props.
257
+ * ```tsx
258
+ * const Component = forwardRef(() => <div />);
259
+ * <Component ref={(current) => console.log(current)} />
260
+ * ```
261
+ *
262
+ * You only need this type if you manually author the types of props that need to be compatible with legacy refs.
263
+ * ```tsx
264
+ * interface Props extends React.RefAttributes<HTMLDivElement> {}
265
+ * declare const Component: React.FunctionComponent<Props>;
266
+ * ```
267
+ *
268
+ * Otherwise it's simpler to directly use {@link Ref} since you can safely use the
269
+ * props type to describe to props that a consumer can pass to the component
270
+ * as well as describing the props the implementation of a component "sees".
271
+ * {@link RefAttributes} is generally not safe to describe both consumer and seen props.
272
+ *
273
+ * ```tsx
274
+ * interface Props extends {
275
+ * ref?: React.Ref<HTMLDivElement> | undefined;
276
+ * }
277
+ * declare const Component: React.FunctionComponent<Props>;
278
+ * ```
279
+ *
280
+ * WARNING: The implementation of a component will not have access to the same type in versions of React supporting string refs.
281
+ * The following example would be incorrect usage because {@link Component} would never have access to a `ref` with type `string`
282
+ * ```tsx
283
+ * const Component = (props: React.RefAttributes) => props.ref;
284
+ * ```
285
+ */
238
286
  interface RefAttributes<T> extends Attributes {
239
287
  /**
240
288
  * Allows getting a ref to the component instance.
@@ -243,21 +291,13 @@ declare namespace React {
243
291
  *
244
292
  * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
245
293
  */
246
- ref?: Ref<T> | undefined;
294
+ ref?: LegacyRef<T> | undefined;
247
295
  }
248
296
 
249
297
  /**
250
298
  * Represents the built-in attributes available to class components.
251
299
  */
252
- interface ClassAttributes<T> extends Attributes {
253
- /**
254
- * Allows getting a ref to the component instance.
255
- * Once the component unmounts, React will set `ref.current` to `null`
256
- * (or call the ref with `null` if you passed a callback ref).
257
- *
258
- * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
259
- */
260
- ref?: LegacyRef<T> | undefined;
300
+ interface ClassAttributes<T> extends RefAttributes<T> {
261
301
  }
262
302
 
263
303
  /**
@@ -284,6 +324,9 @@ declare namespace React {
284
324
  key: string | null;
285
325
  }
286
326
 
327
+ /**
328
+ * @deprecated
329
+ */
287
330
  interface ReactComponentElement<
288
331
  T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
289
332
  P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
@@ -382,7 +425,8 @@ declare namespace React {
382
425
  */
383
426
  interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
384
427
  /**
385
- * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
428
+ * WARNING: Not related to `React.Fragment`.
429
+ * @deprecated This type is not relevant when using React. Inline the type instead to make the intent clear.
386
430
  */
387
431
  type ReactFragment = Iterable<ReactNode>;
388
432
 
@@ -421,6 +465,7 @@ declare namespace React {
421
465
  * <Component customElement={<div>hello</div>} />
422
466
  * ```
423
467
  */
468
+ // non-thenables need to be kept in sync with AwaitedReactNode
424
469
  type ReactNode =
425
470
  | ReactElement
426
471
  | string
@@ -712,6 +757,8 @@ declare namespace React {
712
757
  * ```
713
758
  */
714
759
  function createContext<T>(
760
+ // If you thought this should be optional, see
761
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106
715
762
  defaultValue: T,
716
763
  ): Context<T>;
717
764
 
@@ -1519,6 +1566,7 @@ declare namespace React {
1519
1566
  P extends any ? ("ref" extends keyof P ? Omit<P, "ref"> : P) : P;
1520
1567
  /** Ensures that the props do not include string ref, which cannot be forwarded */
1521
1568
  type PropsWithRef<P> =
1569
+ // Note: String refs can be forwarded. We can't fix this bug without breaking a bunch of libraries now though.
1522
1570
  // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
1523
1571
  "ref" extends keyof P
1524
1572
  ? P extends { ref?: infer R | undefined }
@@ -3137,6 +3185,7 @@ declare namespace React {
3137
3185
  alt?: string | undefined;
3138
3186
  crossOrigin?: CrossOrigin;
3139
3187
  decoding?: "async" | "auto" | "sync" | undefined;
3188
+ fetchPriority?: "high" | "low" | "auto";
3140
3189
  height?: number | string | undefined;
3141
3190
  loading?: "eager" | "lazy" | undefined;
3142
3191
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
@@ -3177,10 +3226,72 @@ declare namespace React {
3177
3226
  | "week"
3178
3227
  | (string & {});
3179
3228
 
3229
+ type AutoFillAddressKind = "billing" | "shipping";
3230
+ type AutoFillBase = "" | "off" | "on";
3231
+ type AutoFillContactField =
3232
+ | "email"
3233
+ | "tel"
3234
+ | "tel-area-code"
3235
+ | "tel-country-code"
3236
+ | "tel-extension"
3237
+ | "tel-local"
3238
+ | "tel-local-prefix"
3239
+ | "tel-local-suffix"
3240
+ | "tel-national";
3241
+ type AutoFillContactKind = "home" | "mobile" | "work";
3242
+ type AutoFillCredentialField = "webauthn";
3243
+ type AutoFillNormalField =
3244
+ | "additional-name"
3245
+ | "address-level1"
3246
+ | "address-level2"
3247
+ | "address-level3"
3248
+ | "address-level4"
3249
+ | "address-line1"
3250
+ | "address-line2"
3251
+ | "address-line3"
3252
+ | "bday-day"
3253
+ | "bday-month"
3254
+ | "bday-year"
3255
+ | "cc-csc"
3256
+ | "cc-exp"
3257
+ | "cc-exp-month"
3258
+ | "cc-exp-year"
3259
+ | "cc-family-name"
3260
+ | "cc-given-name"
3261
+ | "cc-name"
3262
+ | "cc-number"
3263
+ | "cc-type"
3264
+ | "country"
3265
+ | "country-name"
3266
+ | "current-password"
3267
+ | "family-name"
3268
+ | "given-name"
3269
+ | "honorific-prefix"
3270
+ | "honorific-suffix"
3271
+ | "name"
3272
+ | "new-password"
3273
+ | "one-time-code"
3274
+ | "organization"
3275
+ | "postal-code"
3276
+ | "street-address"
3277
+ | "transaction-amount"
3278
+ | "transaction-currency"
3279
+ | "username";
3280
+ type OptionalPrefixToken<T extends string> = `${T} ` | "";
3281
+ type OptionalPostfixToken<T extends string> = ` ${T}` | "";
3282
+ type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`;
3283
+ type AutoFillSection = `section-${string}`;
3284
+ type AutoFill =
3285
+ | AutoFillBase
3286
+ | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<
3287
+ AutoFillAddressKind
3288
+ >}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`;
3289
+ type HTMLInputAutoCompleteAttribute = AutoFill | (string & {});
3290
+
3180
3291
  interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
3181
3292
  accept?: string | undefined;
3182
3293
  alt?: string | undefined;
3183
- autoComplete?: string | undefined;
3294
+ autoComplete?: HTMLInputAutoCompleteAttribute | undefined;
3184
3295
  capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3185
3296
  checked?: boolean | undefined;
3186
3297
  disabled?: boolean | undefined;
@@ -4322,6 +4433,7 @@ declare global {
4322
4433
  polyline: React.SVGProps<SVGPolylineElement>;
4323
4434
  radialGradient: React.SVGProps<SVGRadialGradientElement>;
4324
4435
  rect: React.SVGProps<SVGRectElement>;
4436
+ set: React.SVGProps<SVGSetElement>;
4325
4437
  stop: React.SVGProps<SVGStopElement>;
4326
4438
  switch: React.SVGProps<SVGSwitchElement>;
4327
4439
  symbol: React.SVGProps<SVGSymbolElement>;
@@ -1,4 +1,5 @@
1
1
  import * as React from "./";
2
+ export { Fragment } from "./";
2
3
 
3
4
  export namespace JSX {
4
5
  type ElementType = React.JSX.ElementType;
@@ -11,3 +12,34 @@ export namespace JSX {
11
12
  interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
12
13
  interface IntrinsicElements extends React.JSX.IntrinsicElements {}
13
14
  }
15
+
16
+ export interface JSXSource {
17
+ /**
18
+ * The source file where the element originates from.
19
+ */
20
+ fileName?: string | undefined;
21
+
22
+ /**
23
+ * The line number where the element was created.
24
+ */
25
+ lineNumber?: number | undefined;
26
+
27
+ /**
28
+ * The column number where the element was created.
29
+ */
30
+ columnNumber?: number | undefined;
31
+ }
32
+
33
+ /**
34
+ * Create a React element.
35
+ *
36
+ * You should not use this function directly. Use JSX and a transpiler instead.
37
+ */
38
+ export function jsxDEV(
39
+ type: React.ElementType,
40
+ props: unknown,
41
+ key: React.Key | undefined,
42
+ isStatic: boolean,
43
+ source?: JSXSource,
44
+ self?: unknown,
45
+ ): React.ReactElement;
react/jsx-runtime.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from "./";
2
+ export { Fragment } from "./";
2
3
 
3
4
  export namespace JSX {
4
5
  type ElementType = React.JSX.ElementType;
@@ -11,3 +12,25 @@ export namespace JSX {
11
12
  interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
12
13
  interface IntrinsicElements extends React.JSX.IntrinsicElements {}
13
14
  }
15
+
16
+ /**
17
+ * Create a React element.
18
+ *
19
+ * You should not use this function directly. Use JSX and a transpiler instead.
20
+ */
21
+ export function jsx(
22
+ type: React.ElementType,
23
+ props: unknown,
24
+ key?: React.Key,
25
+ ): React.ReactElement;
26
+
27
+ /**
28
+ * Create a React element.
29
+ *
30
+ * You should not use this function directly. Use JSX and a transpiler instead.
31
+ */
32
+ export function jsxs(
33
+ type: React.ElementType,
34
+ props: unknown,
35
+ key?: React.Key,
36
+ ): React.ReactElement;
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "18.2.55",
3
+ "version": "18.2.65",
4
4
  "description": "TypeScript definitions for react",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
6
6
  "license": "MIT",
@@ -136,6 +136,11 @@
136
136
  "name": "Dmitry Semigradsky",
137
137
  "githubUsername": "Semigradsky",
138
138
  "url": "https://github.com/Semigradsky"
139
+ },
140
+ {
141
+ "name": "Matt Pocock",
142
+ "githubUsername": "mattpocock",
143
+ "url": "https://github.com/mattpocock"
139
144
  }
140
145
  ],
141
146
  "main": "",
@@ -201,6 +206,6 @@
201
206
  "@types/scheduler": "*",
202
207
  "csstype": "^3.0.2"
203
208
  },
204
- "typesPublisherContentHash": "41cc4f9203a010eff4158b37583d535e6867e99253ce9e203f10ddc95a2cdb36",
205
- "typeScriptVersion": "4.6"
209
+ "typesPublisherContentHash": "a8477c63620b49fa941ad9ef8541f4f8138d84d70ce7e2268d9f46a7afc0dbaa",
210
+ "typeScriptVersion": "4.7"
206
211
  }
react/ts5.0/canary.d.ts CHANGED
@@ -95,7 +95,7 @@ declare module "." {
95
95
  /**
96
96
  * Marks all state updates inside the async function as transitions
97
97
  *
98
- * @see {https://react.dev/reference/react/ts5.0/useTransition#starttransition}
98
+ * @see {https://react.dev/reference/react/useTransition#starttransition}
99
99
  *
100
100
  * @param callback
101
101
  */
@@ -42,10 +42,22 @@ declare const UNDEFINED_VOID_ONLY: unique symbol;
42
42
  type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
43
43
 
44
44
  declare module "." {
45
- // Need an interface to not cause ReactNode to be a self-referential type.
46
- interface PromiseLikeOfReactNode extends PromiseLike<ReactNode> {}
45
+ /**
46
+ * @internal Use `Awaited<ReactNode>` instead
47
+ */
48
+ // Helper type to enable `Awaited<ReactNode>`.
49
+ // Must be a copy of the non-thenables of `ReactNode`.
50
+ type AwaitedReactNode =
51
+ | ReactElement
52
+ | string
53
+ | number
54
+ | Iterable<AwaitedReactNode>
55
+ | ReactPortal
56
+ | boolean
57
+ | null
58
+ | undefined;
47
59
  interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {
48
- promises: PromiseLikeOfReactNode;
60
+ promises: Promise<AwaitedReactNode>;
49
61
  }
50
62
 
51
63
  export interface SuspenseProps {
react/ts5.0/global.d.ts CHANGED
@@ -140,6 +140,7 @@ interface SVGPolygonElement extends SVGElement {}
140
140
  interface SVGPolylineElement extends SVGElement {}
141
141
  interface SVGRadialGradientElement extends SVGElement {}
142
142
  interface SVGRectElement extends SVGElement {}
143
+ interface SVGSetElement extends SVGElement {}
143
144
  interface SVGStopElement extends SVGElement {}
144
145
  interface SVGSwitchElement extends SVGElement {}
145
146
  interface SVGSymbolElement extends SVGElement {}
react/ts5.0/index.d.ts CHANGED
@@ -91,8 +91,11 @@ declare namespace React {
91
91
  | ComponentType<P>;
92
92
 
93
93
  /**
94
- * Represents any user-defined component, either as a function component or
95
- * a class component.
94
+ * Represents any user-defined component, either as a function or a class.
95
+ *
96
+ * Similar to {@link JSXElementConstructor}, but with extra properties like
97
+ * {@link FunctionComponent.defaultProps defaultProps } and
98
+ * {@link ComponentClass.contextTypes contextTypes}.
96
99
  *
97
100
  * @template P The props the component accepts.
98
101
  *
@@ -186,6 +189,7 @@ declare namespace React {
186
189
  * <div ref="myRef" />
187
190
  * ```
188
191
  */
192
+ // TODO: Remove the string ref special case from `PropsWithRef` once we remove LegacyRef
189
193
  type LegacyRef<T> = string | Ref<T>;
190
194
 
191
195
  /**
@@ -214,9 +218,10 @@ declare namespace React {
214
218
  > =
215
219
  // need to check first if `ref` is a valid prop for ts@3.0
216
220
  // otherwise it will infer `{}` instead of `never`
217
- "ref" extends keyof ComponentPropsWithRef<C> ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends Ref<
221
+ "ref" extends keyof ComponentPropsWithRef<C>
222
+ ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends RefAttributes<
218
223
  infer Instance
219
- > ? Instance
224
+ >["ref"] ? Instance
220
225
  : never
221
226
  : never;
222
227
 
@@ -230,30 +235,69 @@ declare namespace React {
230
235
  type Key = string | number | bigint;
231
236
 
232
237
  /**
233
- * @internal You shouldn't need to use this type since you never see these attributes
234
- * inside your component or have to validate them.
238
+ * @internal The props any component can receive.
239
+ * You don't have to add this type. All components automatically accept these props.
240
+ * ```tsx
241
+ * const Component = () => <div />;
242
+ * <Component key="one" />
243
+ * ```
244
+ *
245
+ * WARNING: The implementation of a component will never have access to these attributes.
246
+ * The following example would be incorrect usage because {@link Component} would never have access to `key`:
247
+ * ```tsx
248
+ * const Component = (props: React.Attributes) => props.key;
249
+ * ```
235
250
  */
236
251
  interface Attributes {
237
252
  key?: Key | null | undefined;
238
253
  }
254
+ /**
255
+ * The props any component accepting refs can receive.
256
+ * Class components, built-in browser components (e.g. `div`) and forwardRef components can receive refs and automatically accept these props.
257
+ * ```tsx
258
+ * const Component = forwardRef(() => <div />);
259
+ * <Component ref={(current) => console.log(current)} />
260
+ * ```
261
+ *
262
+ * You only need this type if you manually author the types of props that need to be compatible with legacy refs.
263
+ * ```tsx
264
+ * interface Props extends React.RefAttributes<HTMLDivElement> {}
265
+ * declare const Component: React.FunctionComponent<Props>;
266
+ * ```
267
+ *
268
+ * Otherwise it's simpler to directly use {@link Ref} since you can safely use the
269
+ * props type to describe to props that a consumer can pass to the component
270
+ * as well as describing the props the implementation of a component "sees".
271
+ * {@link RefAttributes} is generally not safe to describe both consumer and seen props.
272
+ *
273
+ * ```tsx
274
+ * interface Props extends {
275
+ * ref?: React.Ref<HTMLDivElement> | undefined;
276
+ * }
277
+ * declare const Component: React.FunctionComponent<Props>;
278
+ * ```
279
+ *
280
+ * WARNING: The implementation of a component will not have access to the same type in versions of React supporting string refs.
281
+ * The following example would be incorrect usage because {@link Component} would never have access to a `ref` with type `string`
282
+ * ```tsx
283
+ * const Component = (props: React.RefAttributes) => props.ref;
284
+ * ```
285
+ */
239
286
  interface RefAttributes<T> extends Attributes {
240
287
  /**
241
288
  * Allows getting a ref to the component instance.
242
- * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
243
- * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom}
289
+ * Once the component unmounts, React will set `ref.current` to `null`
290
+ * (or call the ref with `null` if you passed a callback ref).
291
+ *
292
+ * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
244
293
  */
245
- ref?: Ref<T> | undefined;
294
+ ref?: LegacyRef<T> | undefined;
246
295
  }
296
+
247
297
  /**
248
298
  * Represents the built-in attributes available to class components.
249
299
  */
250
- interface ClassAttributes<T> extends Attributes {
251
- /**
252
- * Allows getting a ref to the component instance.
253
- * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
254
- * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom}
255
- */
256
- ref?: LegacyRef<T> | undefined;
300
+ interface ClassAttributes<T> extends RefAttributes<T> {
257
301
  }
258
302
 
259
303
  /**
@@ -280,6 +324,9 @@ declare namespace React {
280
324
  key: string | null;
281
325
  }
282
326
 
327
+ /**
328
+ * @deprecated
329
+ */
283
330
  interface ReactComponentElement<
284
331
  T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
285
332
  P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
@@ -295,7 +342,7 @@ declare namespace React {
295
342
  }
296
343
 
297
344
  /**
298
- * @deprecated Use `ComponentElement<P, ClassicComponent<P, any>>` instead.
345
+ * @deprecated Use {@link ComponentElement} instead.
299
346
  */
300
347
  type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
301
348
 
@@ -379,7 +426,7 @@ declare namespace React {
379
426
  interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
380
427
  /**
381
428
  * WARNING: Not related to `React.Fragment`.
382
- * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
429
+ * @deprecated This type is not relevant when using React. Inline the type instead to make the intent clear.
383
430
  */
384
431
  type ReactFragment = Iterable<ReactNode>;
385
432
 
@@ -419,6 +466,7 @@ declare namespace React {
419
466
  * <Component customElement={<div>hello</div>} />
420
467
  * ```
421
468
  */
469
+ // non-thenables need to be kept in sync with AwaitedReactNode
422
470
  type ReactNode =
423
471
  | ReactElement
424
472
  | string
@@ -898,7 +946,6 @@ declare namespace React {
898
946
  // Base component for plain JS classes
899
947
  interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {}
900
948
  class Component<P, S> {
901
- // tslint won't let me format the sample code in a way that vscode likes it :(
902
949
  /**
903
950
  * If set, `this.context` will be set at runtime to the current value of the given Context.
904
951
  *
@@ -927,7 +974,6 @@ declare namespace React {
927
974
  * Should be used with type annotation or static contextType.
928
975
  *
929
976
  * @example
930
- *
931
977
  * ```ts
932
978
  * static contextType = MyContext
933
979
  * // For TS pre-3.7:
@@ -936,14 +982,14 @@ declare namespace React {
936
982
  * declare context: React.ContextType<typeof MyContext>
937
983
  * ```
938
984
  *
939
- * @see {@link https://react.dev/reference/react/Component#context}
985
+ * @see {@link https://react.dev/reference/react/Component#context React Docs}
940
986
  */
941
987
  context: unknown;
942
988
 
943
989
  constructor(props: Readonly<P> | P);
944
990
  /**
945
991
  * @deprecated
946
- * @see {@link https://legacy.reactjs.org/docs/legacy-context.html}
992
+ * @see {@link https://legacy.reactjs.org/docs/legacy-context.html React Docs}
947
993
  */
948
994
  constructor(props: P, context: any);
949
995
 
@@ -962,7 +1008,8 @@ declare namespace React {
962
1008
  state: Readonly<S>;
963
1009
  /**
964
1010
  * @deprecated
965
- * https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs
1011
+ *
1012
+ * @see {@link https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs}
966
1013
  */
967
1014
  refs: {
968
1015
  [key: string]: ReactInstance;
@@ -1118,6 +1165,7 @@ declare namespace React {
1118
1165
  * @deprecated - Equivalent to {@link React.FunctionComponent}.
1119
1166
  *
1120
1167
  * @see {@link React.FunctionComponent}
1168
+ * @alias {@link VoidFunctionComponent}
1121
1169
  */
1122
1170
  type VFC<P = {}> = VoidFunctionComponent<P>;
1123
1171
 
@@ -1345,7 +1393,7 @@ declare namespace React {
1345
1393
  * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1346
1394
  * this from being invoked.
1347
1395
  *
1348
- * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17
1396
+ * @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead; will stop working in React 17
1349
1397
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
1350
1398
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1351
1399
  */
@@ -1360,7 +1408,7 @@ declare namespace React {
1360
1408
  * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1361
1409
  * this from being invoked.
1362
1410
  *
1363
- * @deprecated 16.3, use componentDidMount or the constructor instead
1411
+ * @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead
1364
1412
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
1365
1413
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1366
1414
  */
@@ -1376,7 +1424,7 @@ declare namespace React {
1376
1424
  * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1377
1425
  * this from being invoked.
1378
1426
  *
1379
- * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17
1427
+ * @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead; will stop working in React 17
1380
1428
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1381
1429
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1382
1430
  */
@@ -1394,7 +1442,7 @@ declare namespace React {
1394
1442
  * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1395
1443
  * this from being invoked.
1396
1444
  *
1397
- * @deprecated 16.3, use static getDerivedStateFromProps instead
1445
+ * @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead
1398
1446
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1399
1447
  * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1400
1448
  */
@@ -1432,7 +1480,9 @@ declare namespace React {
1432
1480
  }
1433
1481
 
1434
1482
  /**
1435
- * @deprecated https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html
1483
+ * @deprecated
1484
+ *
1485
+ * @see {@link https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful}
1436
1486
  */
1437
1487
  interface Mixin<P, S> extends ComponentLifecycle<P, S> {
1438
1488
  mixins?: Array<Mixin<P, S>> | undefined;
@@ -1517,6 +1567,7 @@ declare namespace React {
1517
1567
  P extends any ? ("ref" extends keyof P ? Omit<P, "ref"> : P) : P;
1518
1568
  /** Ensures that the props do not include string ref, which cannot be forwarded */
1519
1569
  type PropsWithRef<P> =
1570
+ // Note: String refs can be forwarded. We can't fix this bug without breaking a bunch of libraries now though.
1520
1571
  // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
1521
1572
  "ref" extends keyof P
1522
1573
  ? P extends { ref?: infer R | undefined }
@@ -1670,9 +1721,11 @@ declare namespace React {
1670
1721
  propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
1671
1722
  ): MemoExoticComponent<T>;
1672
1723
 
1673
- type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
1724
+ interface LazyExoticComponent<T extends ComponentType<any>>
1725
+ extends ExoticComponent<CustomComponentPropsWithRef<T>>
1726
+ {
1674
1727
  readonly _result: T;
1675
- };
1728
+ }
1676
1729
 
1677
1730
  /**
1678
1731
  * Lets you defer loading a component’s code until it is rendered for the first time.
@@ -1702,8 +1755,6 @@ declare namespace React {
1702
1755
  // React Hooks
1703
1756
  // ----------------------------------------------------------------------
1704
1757
 
1705
- // based on the code in https://github.com/facebook/react/pull/13968
1706
-
1707
1758
  /**
1708
1759
  * The instruction passed to a {@link Dispatch} function in {@link useState}
1709
1760
  * to tell React what the next value of the {@link useState} should be.
@@ -3135,6 +3186,7 @@ declare namespace React {
3135
3186
  alt?: string | undefined;
3136
3187
  crossOrigin?: CrossOrigin;
3137
3188
  decoding?: "async" | "auto" | "sync" | undefined;
3189
+ fetchPriority?: "high" | "low" | "auto";
3138
3190
  height?: number | string | undefined;
3139
3191
  loading?: "eager" | "lazy" | undefined;
3140
3192
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
@@ -3175,10 +3227,72 @@ declare namespace React {
3175
3227
  | "week"
3176
3228
  | (string & {});
3177
3229
 
3230
+ type AutoFillAddressKind = "billing" | "shipping";
3231
+ type AutoFillBase = "" | "off" | "on";
3232
+ type AutoFillContactField =
3233
+ | "email"
3234
+ | "tel"
3235
+ | "tel-area-code"
3236
+ | "tel-country-code"
3237
+ | "tel-extension"
3238
+ | "tel-local"
3239
+ | "tel-local-prefix"
3240
+ | "tel-local-suffix"
3241
+ | "tel-national";
3242
+ type AutoFillContactKind = "home" | "mobile" | "work";
3243
+ type AutoFillCredentialField = "webauthn";
3244
+ type AutoFillNormalField =
3245
+ | "additional-name"
3246
+ | "address-level1"
3247
+ | "address-level2"
3248
+ | "address-level3"
3249
+ | "address-level4"
3250
+ | "address-line1"
3251
+ | "address-line2"
3252
+ | "address-line3"
3253
+ | "bday-day"
3254
+ | "bday-month"
3255
+ | "bday-year"
3256
+ | "cc-csc"
3257
+ | "cc-exp"
3258
+ | "cc-exp-month"
3259
+ | "cc-exp-year"
3260
+ | "cc-family-name"
3261
+ | "cc-given-name"
3262
+ | "cc-name"
3263
+ | "cc-number"
3264
+ | "cc-type"
3265
+ | "country"
3266
+ | "country-name"
3267
+ | "current-password"
3268
+ | "family-name"
3269
+ | "given-name"
3270
+ | "honorific-prefix"
3271
+ | "honorific-suffix"
3272
+ | "name"
3273
+ | "new-password"
3274
+ | "one-time-code"
3275
+ | "organization"
3276
+ | "postal-code"
3277
+ | "street-address"
3278
+ | "transaction-amount"
3279
+ | "transaction-currency"
3280
+ | "username";
3281
+ type OptionalPrefixToken<T extends string> = `${T} ` | "";
3282
+ type OptionalPostfixToken<T extends string> = ` ${T}` | "";
3283
+ type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`;
3284
+ type AutoFillSection = `section-${string}`;
3285
+ type AutoFill =
3286
+ | AutoFillBase
3287
+ | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<
3288
+ AutoFillAddressKind
3289
+ >}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`;
3290
+ type HTMLInputAutoCompleteAttribute = AutoFill | (string & {});
3291
+
3178
3292
  interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
3179
3293
  accept?: string | undefined;
3180
3294
  alt?: string | undefined;
3181
- autoComplete?: string | undefined;
3295
+ autoComplete?: HTMLInputAutoCompleteAttribute | undefined;
3182
3296
  capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3183
3297
  checked?: boolean | undefined;
3184
3298
  disabled?: boolean | undefined;
@@ -4043,9 +4157,11 @@ declare namespace React {
4043
4157
  /**
4044
4158
  * Captures which component contained the exception, and its ancestors.
4045
4159
  */
4046
- componentStack: string;
4160
+ componentStack?: string | null;
4161
+ digest?: string | null;
4047
4162
  }
4048
4163
 
4164
+ // Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
4049
4165
  namespace JSX {
4050
4166
  interface Element extends GlobalJSXElement {}
4051
4167
  interface ElementClass extends GlobalJSXElementClass {}
@@ -4305,6 +4421,7 @@ declare global {
4305
4421
  polyline: React.SVGProps<SVGPolylineElement>;
4306
4422
  radialGradient: React.SVGProps<SVGRadialGradientElement>;
4307
4423
  rect: React.SVGProps<SVGRectElement>;
4424
+ set: React.SVGProps<SVGSetElement>;
4308
4425
  stop: React.SVGProps<SVGStopElement>;
4309
4426
  switch: React.SVGProps<SVGSwitchElement>;
4310
4427
  symbol: React.SVGProps<SVGSymbolElement>;
@@ -1,4 +1,5 @@
1
1
  import * as React from "./";
2
+ export { Fragment } from "./";
2
3
 
3
4
  export namespace JSX {
4
5
  interface Element extends React.JSX.Element {}
@@ -10,3 +11,34 @@ export namespace JSX {
10
11
  interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
11
12
  interface IntrinsicElements extends React.JSX.IntrinsicElements {}
12
13
  }
14
+
15
+ export interface JSXSource {
16
+ /**
17
+ * The source file where the element originates from.
18
+ */
19
+ fileName?: string | undefined;
20
+
21
+ /**
22
+ * The line number where the element was created.
23
+ */
24
+ lineNumber?: number | undefined;
25
+
26
+ /**
27
+ * The column number where the element was created.
28
+ */
29
+ columnNumber?: number | undefined;
30
+ }
31
+
32
+ /**
33
+ * Create a React element.
34
+ *
35
+ * You should not use this function directly. Use JSX and a transpiler instead.
36
+ */
37
+ export function jsxDEV(
38
+ type: React.ElementType,
39
+ props: unknown,
40
+ key: React.Key | undefined,
41
+ isStatic: boolean,
42
+ source?: JSXSource,
43
+ self?: unknown,
44
+ ): React.ReactElement;
@@ -1,4 +1,5 @@
1
1
  import * as React from "./";
2
+ export { Fragment } from "./";
2
3
 
3
4
  export namespace JSX {
4
5
  interface Element extends React.JSX.Element {}
@@ -10,3 +11,25 @@ export namespace JSX {
10
11
  interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
11
12
  interface IntrinsicElements extends React.JSX.IntrinsicElements {}
12
13
  }
14
+
15
+ /**
16
+ * Create a React element.
17
+ *
18
+ * You should not use this function directly. Use JSX and a transpiler instead.
19
+ */
20
+ export function jsx(
21
+ type: React.ElementType,
22
+ props: unknown,
23
+ key?: React.Key,
24
+ ): React.ReactElement;
25
+
26
+ /**
27
+ * Create a React element.
28
+ *
29
+ * You should not use this function directly. Use JSX and a transpiler instead.
30
+ */
31
+ export function jsxs(
32
+ type: React.ElementType,
33
+ props: unknown,
34
+ key?: React.Key,
35
+ ): React.ReactElement;