@types/react 17.0.58 → 18.0.35

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.
@@ -5,12 +5,12 @@
5
5
  This package contains type definitions for React (https://react.dev/).
6
6
 
7
7
  # Details
8
- Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react/v17.
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 12 Apr 2023 10:33:22 GMT
11
+ * Last updated: Wed, 12 Apr 2023 10:33:21 GMT
12
12
  * Dependencies: [@types/csstype](https://npmjs.com/package/@types/csstype), [@types/prop-types](https://npmjs.com/package/@types/prop-types), [@types/scheduler](https://npmjs.com/package/@types/scheduler)
13
13
  * Global values: `React`
14
14
 
15
15
  # Credits
16
- 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), and [Priyanshu Rav](https://github.com/priyanshurav).
16
+ 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).
@@ -0,0 +1,108 @@
1
+ /**
2
+ * These are types for things that are present in the `experimental` builds of React but not yet
3
+ * on a stable build.
4
+ *
5
+ * Once they are promoted to stable they can just be moved to the main index file.
6
+ *
7
+ * To load the types declared here in an actual project, there are three ways. The easiest one,
8
+ * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
9
+ * is to add `"react/experimental"` to the `"types"` array.
10
+ *
11
+ * Alternatively, a specific import syntax can to be used from a typescript file.
12
+ * This module does not exist in reality, which is why the {} is important:
13
+ *
14
+ * ```ts
15
+ * import {} from 'react/experimental'
16
+ * ```
17
+ *
18
+ * It is also possible to include it through a triple-slash reference:
19
+ *
20
+ * ```ts
21
+ * /// <reference types="react/experimental" />
22
+ * ```
23
+ *
24
+ * Either the import or the reference only needs to appear once, anywhere in the project.
25
+ */
26
+
27
+ // See https://github.com/facebook/react/blob/master/packages/react/src/React.js to see how the exports are declared,
28
+ // and https://github.com/facebook/react/blob/master/packages/shared/ReactFeatureFlags.js to verify which APIs are
29
+ // flagged experimental or not. Experimental APIs will be tagged with `__EXPERIMENTAL__`.
30
+ //
31
+ // For the inputs of types exported as simply a fiber tag, the `beginWork` function of ReactFiberBeginWork.js
32
+ // is a good place to start looking for details; it generally calls prop validation functions or delegates
33
+ // all tasks done as part of the render phase (the concurrent part of the React update cycle).
34
+ //
35
+ // Suspense-related handling can be found in ReactFiberThrow.js.
36
+
37
+ import React = require('./next');
38
+
39
+ export {};
40
+
41
+ declare module '.' {
42
+ export interface SuspenseProps {
43
+ /**
44
+ * The presence of this prop indicates that the content is computationally expensive to render.
45
+ * In other words, the tree is CPU bound and not I/O bound (e.g. due to fetching data).
46
+ * @see {@link https://github.com/facebook/react/pull/19936}
47
+ */
48
+ unstable_expectedLoadTime?: number | undefined;
49
+ }
50
+
51
+ export type SuspenseListRevealOrder = 'forwards' | 'backwards' | 'together';
52
+ export type SuspenseListTailMode = 'collapsed' | 'hidden';
53
+
54
+ export interface SuspenseListCommonProps {
55
+ /**
56
+ * Note that SuspenseList require more than one child;
57
+ * it is a runtime warning to provide only a single child.
58
+ *
59
+ * It does, however, allow those children to be wrapped inside a single
60
+ * level of `<React.Fragment>`.
61
+ */
62
+ children: ReactElement | Iterable<ReactElement>;
63
+ }
64
+
65
+ interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
66
+ /**
67
+ * Defines the order in which the `SuspenseList` children should be revealed.
68
+ */
69
+ revealOrder: 'forwards' | 'backwards';
70
+ /**
71
+ * Dictates how unloaded items in a SuspenseList is shown.
72
+ *
73
+ * - By default, `SuspenseList` will show all fallbacks in the list.
74
+ * - `collapsed` shows only the next fallback in the list.
75
+ * - `hidden` doesn’t show any unloaded items.
76
+ */
77
+ tail?: SuspenseListTailMode | undefined;
78
+ }
79
+
80
+ interface NonDirectionalSuspenseListProps extends SuspenseListCommonProps {
81
+ /**
82
+ * Defines the order in which the `SuspenseList` children should be revealed.
83
+ */
84
+ revealOrder?: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps['revealOrder']> | undefined;
85
+ /**
86
+ * The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
87
+ */
88
+ tail?: never | undefined;
89
+ }
90
+
91
+ export type SuspenseListProps = DirectionalSuspenseListProps | NonDirectionalSuspenseListProps;
92
+
93
+ /**
94
+ * `SuspenseList` helps coordinate many components that can suspend by orchestrating the order
95
+ * in which these components are revealed to the user.
96
+ *
97
+ * When multiple components need to fetch data, this data may arrive in an unpredictable order.
98
+ * However, if you wrap these items in a `SuspenseList`, React will not show an item in the list
99
+ * until previous items have been displayed (this behavior is adjustable).
100
+ *
101
+ * @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist
102
+ * @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist
103
+ */
104
+ export const SuspenseList: ExoticComponent<SuspenseListProps>;
105
+
106
+ // tslint:disable-next-line ban-types
107
+ export function experimental_useEffectEvent<T extends Function>(event: T): T;
108
+ }
@@ -1,4 +1,4 @@
1
- // Type definitions for React 17.0
1
+ // Type definitions for React 18.0
2
2
  // Project: https://react.dev/
3
3
  // Definitions by: Asana <https://asana.com>
4
4
  // AssureSign <http://www.assuresign.com>
@@ -26,9 +26,14 @@
26
26
  // Victor Magalhães <https://github.com/vhfmag>
27
27
  // Dale Tan <https://github.com/hellatan>
28
28
  // Priyanshu Rav <https://github.com/priyanshurav>
29
+ // Dmitry Semigradsky <https://github.com/Semigradsky>
29
30
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
30
31
  // TypeScript Version: 2.8
31
32
 
33
+ // NOTE: Users of the `experimental` builds of React should add a reference
34
+ // to 'react/experimental' in their project. See experimental.d.ts's top comment
35
+ // for reference and documentation on how exactly to do it.
36
+
32
37
  /// <reference path="global.d.ts" />
33
38
 
34
39
  import * as CSS from 'csstype';
@@ -52,6 +57,7 @@ type Booleanish = boolean | 'true' | 'false';
52
57
  declare const UNDEFINED_VOID_ONLY: unique symbol;
53
58
  // Destructors are only allowed to return void.
54
59
  type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };
60
+ type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
55
61
 
56
62
  // eslint-disable-next-line export-just-namespace
57
63
  export = React;
@@ -67,10 +73,6 @@ declare namespace React {
67
73
  [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never
68
74
  }[keyof JSX.IntrinsicElements] |
69
75
  ComponentType<P>;
70
- /**
71
- * @deprecated Please use `ElementType`
72
- */
73
- type ReactType<P = any> = ElementType<P>;
74
76
  type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
75
77
 
76
78
  type JSXElementConstructor<P> =
@@ -130,9 +132,19 @@ declare namespace React {
130
132
  key?: Key | null | undefined;
131
133
  }
132
134
  interface RefAttributes<T> extends Attributes {
135
+ /**
136
+ * Allows getting a ref to the component instance.
137
+ * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
138
+ * @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
139
+ */
133
140
  ref?: Ref<T> | undefined;
134
141
  }
135
142
  interface ClassAttributes<T> extends Attributes {
143
+ /**
144
+ * Allows getting a ref to the component instance.
145
+ * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
146
+ * @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
147
+ */
136
148
  ref?: LegacyRef<T> | undefined;
137
149
  }
138
150
 
@@ -147,11 +159,6 @@ declare namespace React {
147
159
  P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, 'key' | 'ref'>>
148
160
  > extends ReactElement<P, Exclude<T, number>> { }
149
161
 
150
- /**
151
- * @deprecated Please use `FunctionComponentElement`
152
- */
153
- type SFCElement<P> = FunctionComponentElement<P>;
154
-
155
162
  interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
156
163
  ref?: ('ref' extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
157
164
  }
@@ -217,19 +224,21 @@ declare namespace React {
217
224
  (props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null, ...children: ReactNode[]): ReactSVGElement;
218
225
  }
219
226
 
220
- //
221
- // React Nodes
222
- // ----------------------------------------------------------------------
223
-
227
+ /**
228
+ * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
229
+ */
224
230
  type ReactText = string | number;
225
- type ReactChild = ReactElement | ReactText;
231
+ /**
232
+ * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.
233
+ */
234
+ type ReactChild = ReactElement | string | number;
226
235
 
227
236
  /**
228
237
  * @deprecated Use either `ReactNode[]` if you need an array or `Iterable<ReactNode>` if its passed to a host component.
229
238
  */
230
239
  interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
231
- type ReactFragment = {} | Iterable<ReactNode>;
232
- type ReactNode = ReactChild | ReactFragment | ReactPortal | boolean | null | undefined;
240
+ type ReactFragment = Iterable<ReactNode>;
241
+ type ReactNode = ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined;
233
242
 
234
243
  //
235
244
  // Top Level API
@@ -380,28 +389,30 @@ declare namespace React {
380
389
 
381
390
  function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
382
391
 
383
- const Children: ReactChildren;
392
+ // Sync with `ReactChildren` until `ReactChildren` is removed.
393
+ const Children: {
394
+ map<T, C>(children: C | ReadonlyArray<C>, fn: (child: C, index: number) => T):
395
+ C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
396
+ forEach<C>(children: C | ReadonlyArray<C>, fn: (child: C, index: number) => void): void;
397
+ count(children: any): number;
398
+ only<C>(children: C): C extends any[] ? never : C;
399
+ toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
400
+ };
384
401
  const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
385
402
  const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;
386
403
 
387
404
  interface SuspenseProps {
388
405
  children?: ReactNode | undefined;
389
406
 
390
- // TODO(react18): `fallback?: ReactNode;`
391
407
  /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
392
- fallback: NonNullable<ReactNode>|null;
408
+ fallback?: ReactNode;
393
409
  }
394
410
 
395
- // TODO(react18): Updated JSDoc to reflect that Suspense works on the server.
396
- /**
397
- * This feature is not yet available for server-side rendering.
398
- * Suspense support will be added in a later release.
399
- */
400
411
  const Suspense: ExoticComponent<SuspenseProps>;
401
412
  const version: string;
402
413
 
403
414
  /**
404
- * {@link https://react.dev/reference/react/Profiler#onrender-callback Profiler API}}
415
+ * {@link https://react.dev/reference/react/Profiler#onrender-callback Profiler API}
405
416
  */
406
417
  type ProfilerOnRenderCallback = (
407
418
  id: string,
@@ -467,8 +478,7 @@ declare namespace React {
467
478
  *
468
479
  * @see https://react.dev/reference/react/Component#context
469
480
  */
470
- // TODO (TypeScript 3.0): unknown
471
- context: any;
481
+ context: unknown;
472
482
 
473
483
  constructor(props: Readonly<P> | P);
474
484
  /**
@@ -488,12 +498,7 @@ declare namespace React {
488
498
  forceUpdate(callback?: () => void): void;
489
499
  render(): ReactNode;
490
500
 
491
- // React.Props<T> is now deprecated, which means that the `children`
492
- // property is not available on `P` by default, even though you can
493
- // always pass children as variadic arguments to `createElement`.
494
- // In the future, if we can define its call signature conditionally
495
- // on the existence of `children` in `P`, then we should remove this.
496
- readonly props: Readonly<P> & Readonly<{ children?: ReactNode | undefined }>;
501
+ readonly props: Readonly<P>;
497
502
  state: Readonly<S>;
498
503
  /**
499
504
  * @deprecated
@@ -520,34 +525,24 @@ declare namespace React {
520
525
  // Class Interfaces
521
526
  // ----------------------------------------------------------------------
522
527
 
523
- /**
524
- * @deprecated as of recent React versions, function components can no
525
- * longer be considered 'stateless'. Please use `FunctionComponent` instead.
526
- *
527
- * @see [React Hooks](https://reactjs.org/docs/hooks-intro.html)
528
- */
529
- type SFC<P = {}> = FunctionComponent<P>;
530
-
531
- /**
532
- * @deprecated as of recent React versions, function components can no
533
- * longer be considered 'stateless'. Please use `FunctionComponent` instead.
534
- *
535
- * @see [React Hooks](https://reactjs.org/docs/hooks-intro.html)
536
- */
537
- type StatelessComponent<P = {}> = FunctionComponent<P>;
538
-
539
528
  type FC<P = {}> = FunctionComponent<P>;
540
529
 
541
530
  interface FunctionComponent<P = {}> {
542
- (props: PropsWithChildren<P>, context?: any): ReactElement<any, any> | null;
531
+ (props: P, context?: any): ReactElement<any, any> | null;
543
532
  propTypes?: WeakValidationMap<P> | undefined;
544
533
  contextTypes?: ValidationMap<any> | undefined;
545
534
  defaultProps?: Partial<P> | undefined;
546
535
  displayName?: string | undefined;
547
536
  }
548
537
 
538
+ /**
539
+ * @deprecated - Equivalent with `React.FC`.
540
+ */
549
541
  type VFC<P = {}> = VoidFunctionComponent<P>;
550
542
 
543
+ /**
544
+ * @deprecated - Equivalent with `React.FunctionComponent`.
545
+ */
551
546
  interface VoidFunctionComponent<P = {}> {
552
547
  (props: P, context?: any): ReactElement<any, any> | null;
553
548
  propTypes?: WeakValidationMap<P> | undefined;
@@ -559,7 +554,7 @@ declare namespace React {
559
554
  type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
560
555
 
561
556
  interface ForwardRefRenderFunction<T, P = {}> {
562
- (props: PropsWithChildren<P>, ref: ForwardedRef<T>): ReactElement | null;
557
+ (props: P, ref: ForwardedRef<T>): ReactElement | null;
563
558
  displayName?: string | undefined;
564
559
  // explicit rejected with `never` required due to
565
560
  // https://github.com/microsoft/TypeScript/issues/36826
@@ -573,12 +568,6 @@ declare namespace React {
573
568
  propTypes?: never | undefined;
574
569
  }
575
570
 
576
- /**
577
- * @deprecated Use ForwardRefRenderFunction. forwardRef doesn't accept a
578
- * "real" component.
579
- */
580
- interface RefForwardingComponent <T, P = {}> extends ForwardRefRenderFunction<T, P> {}
581
-
582
571
  interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
583
572
  new (props: P, context?: any): Component<P, S>;
584
573
  propTypes?: WeakValidationMap<P> | undefined;
@@ -803,10 +792,10 @@ declare namespace React {
803
792
 
804
793
  /** Ensures that the props do not include ref at all */
805
794
  type PropsWithoutRef<P> =
806
- // Pick would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
795
+ // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
807
796
  // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
808
797
  // https://github.com/Microsoft/TypeScript/issues/28339
809
- P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;
798
+ P extends any ? ('ref' extends keyof P ? Omit<P, 'ref'> : P) : P;
810
799
  /** Ensures that the props do not include string ref, which cannot be forwarded */
811
800
  type PropsWithRef<P> =
812
801
  // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
@@ -818,7 +807,7 @@ declare namespace React {
818
807
  : P
819
808
  : P;
820
809
 
821
- type PropsWithChildren<P> = P & { children?: ReactNode | undefined };
810
+ type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
822
811
 
823
812
  /**
824
813
  * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,
@@ -853,7 +842,7 @@ declare namespace React {
853
842
 
854
843
  function memo<P extends object>(
855
844
  Component: FunctionComponent<P>,
856
- propsAreEqual?: (prevProps: Readonly<PropsWithChildren<P>>, nextProps: Readonly<PropsWithChildren<P>>) => boolean
845
+ propsAreEqual?: (prevProps: Readonly<P>, nextProps: Readonly<P>) => boolean
857
846
  ): NamedExoticComponent<P>;
858
847
  function memo<T extends ComponentType<any>>(
859
848
  Component: T,
@@ -892,8 +881,7 @@ declare namespace React {
892
881
  // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
893
882
  type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> =
894
883
  R extends ReducerWithoutAction<infer S> ? S : never;
895
- // TODO (TypeScript 3.0): ReadonlyArray<unknown>
896
- type DependencyList = ReadonlyArray<any>;
884
+ type DependencyList = ReadonlyArray<unknown>;
897
885
 
898
886
  // NOTE: callbacks are _only_ allowed to return either void, or a destructor.
899
887
  type EffectCallback = () => (void | Destructor);
@@ -1100,8 +1088,10 @@ declare namespace React {
1100
1088
  * @version 16.8.0
1101
1089
  * @see https://react.dev/reference/react/useCallback
1102
1090
  */
1103
- // TODO (TypeScript 3.0): <T extends (...args: never[]) => unknown>
1104
- function useCallback<T extends (...args: any[]) => any>(callback: T, deps: DependencyList): T;
1091
+ // A specific function type would not trigger implicit any.
1092
+ // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
1093
+ // tslint:disable-next-line ban-types
1094
+ function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
1105
1095
  /**
1106
1096
  * `useMemo` will only recompute the memoized value when one of the `deps` has changed.
1107
1097
  *
@@ -1123,6 +1113,81 @@ declare namespace React {
1123
1113
  // it's just the function name without the "use" prefix.
1124
1114
  function useDebugValue<T>(value: T, format?: (value: T) => any): void;
1125
1115
 
1116
+ // must be synchronous
1117
+ export type TransitionFunction = () => VoidOrUndefinedOnly;
1118
+ // strange definition to allow vscode to show documentation on the invocation
1119
+ export interface TransitionStartFunction {
1120
+ /**
1121
+ * State updates caused inside the callback are allowed to be deferred.
1122
+ *
1123
+ * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
1124
+ *
1125
+ * @param callback A _synchronous_ function which causes state updates that can be deferred.
1126
+ */
1127
+ (callback: TransitionFunction): void;
1128
+ }
1129
+
1130
+ /**
1131
+ * Returns a deferred version of the value that may “lag behind” it.
1132
+ *
1133
+ * This is commonly used to keep the interface responsive when you have something that renders immediately
1134
+ * based on user input and something that needs to wait for a data fetch.
1135
+ *
1136
+ * A good example of this is a text input.
1137
+ *
1138
+ * @param value The value that is going to be deferred
1139
+ *
1140
+ * @see https://react.dev/reference/react/useDeferredValue
1141
+ */
1142
+ export function useDeferredValue<T>(value: T): T;
1143
+
1144
+ /**
1145
+ * Allows components to avoid undesirable loading states by waiting for content to load
1146
+ * before transitioning to the next screen. It also allows components to defer slower,
1147
+ * data fetching updates until subsequent renders so that more crucial updates can be
1148
+ * rendered immediately.
1149
+ *
1150
+ * The `useTransition` hook returns two values in an array.
1151
+ *
1152
+ * The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish.
1153
+ * The second is a function that takes a callback. We can use it to tell React which state we want to defer.
1154
+ *
1155
+ * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**`
1156
+ *
1157
+ * @see https://react.dev/reference/react/useTransition
1158
+ */
1159
+ export function useTransition(): [boolean, TransitionStartFunction];
1160
+
1161
+ /**
1162
+ * Similar to `useTransition` but allows uses where hooks are not available.
1163
+ *
1164
+ * @param callback A _synchronous_ function which causes state updates that can be deferred.
1165
+ */
1166
+ export function startTransition(scope: TransitionFunction): void;
1167
+
1168
+ export function useId(): string;
1169
+
1170
+ /**
1171
+ * @param effect Imperative function that can return a cleanup function
1172
+ * @param deps If present, effect will only activate if the values in the list change.
1173
+ *
1174
+ * @see https://github.com/facebook/react/pull/21913
1175
+ */
1176
+ export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void;
1177
+
1178
+ /**
1179
+ * @param subscribe
1180
+ * @param getSnapshot
1181
+ *
1182
+ * @see https://github.com/reactwg/react-18/discussions/86
1183
+ */
1184
+ // keep in sync with `useSyncExternalStore` from `use-sync-external-store`
1185
+ export function useSyncExternalStore<Snapshot>(
1186
+ subscribe: (onStoreChange: () => void) => () => void,
1187
+ getSnapshot: () => Snapshot,
1188
+ getServerSnapshot?: () => Snapshot,
1189
+ ): Snapshot;
1190
+
1126
1191
  //
1127
1192
  // Event System
1128
1193
  // ----------------------------------------------------------------------
@@ -1309,26 +1374,6 @@ declare namespace React {
1309
1374
  // Props / DOM Attributes
1310
1375
  // ----------------------------------------------------------------------
1311
1376
 
1312
- /**
1313
- * @deprecated. This was used to allow clients to pass `ref` and `key`
1314
- * to `createElement`, which is no longer necessary due to intersection
1315
- * types. If you need to declare a props object before passing it to
1316
- * `createElement` or a factory, use `ClassAttributes<T>`:
1317
- *
1318
- * ```ts
1319
- * var b: Button | null;
1320
- * var props: ButtonProps & ClassAttributes<Button> = {
1321
- * ref: b => button = b, // ok!
1322
- * label: "I'm a Button"
1323
- * };
1324
- * ```
1325
- */
1326
- interface Props<T> {
1327
- children?: ReactNode | undefined;
1328
- key?: Key | undefined;
1329
- ref?: LegacyRef<T> | undefined;
1330
- }
1331
-
1332
1377
  interface HTMLProps<T> extends AllHTMLAttributes<T>, ClassAttributes<T> {
1333
1378
  }
1334
1379
 
@@ -1428,6 +1473,8 @@ declare namespace React {
1428
1473
  onProgressCapture?: ReactEventHandler<T> | undefined;
1429
1474
  onRateChange?: ReactEventHandler<T> | undefined;
1430
1475
  onRateChangeCapture?: ReactEventHandler<T> | undefined;
1476
+ onResize?: ReactEventHandler<T> | undefined;
1477
+ onResizeCapture?: ReactEventHandler<T> | undefined;
1431
1478
  onSeeked?: ReactEventHandler<T> | undefined;
1432
1479
  onSeekedCapture?: ReactEventHandler<T> | undefined;
1433
1480
  onSeeking?: ReactEventHandler<T> | undefined;
@@ -2246,6 +2293,7 @@ declare namespace React {
2246
2293
  integrity?: string | undefined;
2247
2294
  media?: string | undefined;
2248
2295
  imageSrcSet?: string | undefined;
2296
+ imageSizes?: string | undefined;
2249
2297
  referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2250
2298
  sizes?: string | undefined;
2251
2299
  type?: string | undefined;
@@ -2386,8 +2434,13 @@ declare namespace React {
2386
2434
  }
2387
2435
 
2388
2436
  interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
2437
+ align?: "left" | "center" | "right" | undefined;
2438
+ bgcolor?: string | undefined;
2439
+ border?: number | undefined;
2389
2440
  cellPadding?: number | string | undefined;
2390
2441
  cellSpacing?: number | string | undefined;
2442
+ frame?: boolean | undefined;
2443
+ rules?: "none" | "groups" | "rows" | "columns" | "all" | undefined;
2391
2444
  summary?: string | undefined;
2392
2445
  width?: number | string | undefined;
2393
2446
  }
@@ -2772,6 +2825,7 @@ declare namespace React {
2772
2825
  button: DetailedHTMLFactory<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
2773
2826
  canvas: DetailedHTMLFactory<CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
2774
2827
  caption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2828
+ center: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2775
2829
  cite: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2776
2830
  code: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2777
2831
  col: DetailedHTMLFactory<ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
@@ -2973,6 +3027,10 @@ declare namespace React {
2973
3027
  // React.Children
2974
3028
  // ----------------------------------------------------------------------
2975
3029
 
3030
+ /**
3031
+ * @deprecated - Use `typeof React.Children` instead.
3032
+ */
3033
+ // Sync with type of `const Children`.
2976
3034
  interface ReactChildren {
2977
3035
  map<T, C>(children: C | ReadonlyArray<C>, fn: (child: C, index: number) => T):
2978
3036
  C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
@@ -3044,6 +3102,8 @@ type MergePropTypes<P, T> =
3044
3102
  & Pick<P, Exclude<keyof P, keyof T>>
3045
3103
  : never;
3046
3104
 
3105
+ type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
3106
+
3047
3107
  // Any prop that has a default prop becomes optional, but its type is unchanged
3048
3108
  // Undeclared default props are augmented into the resulting allowable attributes
3049
3109
  // If declared props have indexed properties, ignore default props entirely as keyof gets widened
@@ -3051,8 +3111,8 @@ type MergePropTypes<P, T> =
3051
3111
  type Defaultize<P, D> = P extends any
3052
3112
  ? string extends keyof P ? P :
3053
3113
  & Pick<P, Exclude<keyof P, keyof D>>
3054
- & Partial<Pick<P, Extract<keyof P, keyof D>>>
3055
- & Partial<Pick<D, Exclude<keyof D, keyof P>>>
3114
+ & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
3115
+ & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
3056
3116
  : never;
3057
3117
 
3058
3118
  type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D; }
@@ -3103,6 +3163,7 @@ declare global {
3103
3163
  button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
3104
3164
  canvas: React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
3105
3165
  caption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3166
+ center: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3106
3167
  cite: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3107
3168
  code: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3108
3169
  col: React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
react/next.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * These are types for things that are present in the React `next` release channel.
3
+ *
4
+ * To load the types declared here in an actual project, there are three ways. The easiest one,
5
+ * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
6
+ * is to add `"react/next"` to the `"types"` array.
7
+ *
8
+ * Alternatively, a specific import syntax can to be used from a typescript file.
9
+ * This module does not exist in reality, which is why the {} is important:
10
+ *
11
+ * ```ts
12
+ * import {} from 'react/next'
13
+ * ```
14
+ *
15
+ * It is also possible to include it through a triple-slash reference:
16
+ *
17
+ * ```ts
18
+ * /// <reference types="react/next" />
19
+ * ```
20
+ *
21
+ * Either the import or the reference only needs to appear once, anywhere in the project.
22
+ */
23
+
24
+ // See https://github.com/facebook/react/blob/main/packages/react/src/React.js to see how the exports are declared,
25
+
26
+ import React = require('.');
27
+
28
+ export {};
29
+
30
+ declare module '.' {
31
+ interface ThenableImpl<T> {
32
+ then(onFulfill: (value: T) => unknown, onReject: (error: unknown) => unknown): void | PromiseLike<unknown>;
33
+ }
34
+ interface UntrackedThenable<T> extends ThenableImpl<T> {
35
+ status?: void;
36
+ }
37
+
38
+ export interface PendingThenable<T> extends ThenableImpl<T> {
39
+ status: 'pending';
40
+ }
41
+
42
+ export interface FulfilledThenable<T> extends ThenableImpl<T> {
43
+ status: 'fulfilled';
44
+ value: T;
45
+ }
46
+
47
+ export interface RejectedThenable<T> extends ThenableImpl<T> {
48
+ status: 'rejected';
49
+ reason: unknown;
50
+ }
51
+
52
+ export type Thenable<T> = UntrackedThenable<T> | PendingThenable<T> | FulfilledThenable<T> | RejectedThenable<T>;
53
+
54
+ export type Usable<T> = Thenable<T> | Context<T>;
55
+
56
+ export function use<T>(usable: Usable<T>): T;
57
+
58
+ interface ServerContextJSONArray extends ReadonlyArray<ServerContextJSONArray> {}
59
+ export type ServerContextJSONValue =
60
+ | string
61
+ | boolean
62
+ | number
63
+ | null
64
+ | ServerContextJSONArray
65
+ | { [key: string]: ServerContextJSONValue };
66
+ export interface ServerContext<T extends ServerContextJSONValue> {
67
+ Provider: Provider<T>;
68
+ }
69
+ /**
70
+ * Accepts a context object (the value returned from `React.createContext` or `React.createServerContext`) and returns the current
71
+ * context value, as given by the nearest context provider for the given context.
72
+ *
73
+ * @version 16.8.0
74
+ * @see https://react.dev/reference/react/useContext
75
+ */
76
+ function useContext<T extends ServerContextJSONValue>(context: ServerContext<T>): T;
77
+ export function createServerContext<T extends ServerContextJSONValue>(
78
+ globalName: string,
79
+ defaultValue: T,
80
+ ): ServerContext<T>;
81
+
82
+ // tslint:disable-next-line ban-types
83
+ export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
84
+
85
+ export function unstable_useCacheRefresh(): () => void;
86
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "17.0.58",
3
+ "version": "18.0.35",
4
4
  "description": "TypeScript definitions for React",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
6
6
  "license": "MIT",
@@ -131,6 +131,11 @@
131
131
  "name": "Priyanshu Rav",
132
132
  "url": "https://github.com/priyanshurav",
133
133
  "githubUsername": "priyanshurav"
134
+ },
135
+ {
136
+ "name": "Dmitry Semigradsky",
137
+ "url": "https://github.com/Semigradsky",
138
+ "githubUsername": "Semigradsky"
134
139
  }
135
140
  ],
136
141
  "main": "",
@@ -146,7 +151,7 @@
146
151
  "@types/scheduler": "*",
147
152
  "csstype": "^3.0.2"
148
153
  },
149
- "typesPublisherContentHash": "d210231952550d2798f7d6d46ca5a597dc9ae62772849c1d4fed86490fb55694",
154
+ "typesPublisherContentHash": "1bcb6e14c19458140687c02d9c7ef264748e6613f0691aca2f803364e54c1529",
150
155
  "typeScriptVersion": "4.3",
151
156
  "exports": {
152
157
  ".": {
@@ -154,6 +159,16 @@
154
159
  "default": "./index.d.ts"
155
160
  }
156
161
  },
162
+ "./next": {
163
+ "types": {
164
+ "default": "./next.d.ts"
165
+ }
166
+ },
167
+ "./experimental": {
168
+ "types": {
169
+ "default": "./experimental.d.ts"
170
+ }
171
+ },
157
172
  "./jsx-runtime": {
158
173
  "types": {
159
174
  "default": "./jsx-runtime.d.ts"
File without changes
File without changes
File without changes
File without changes