@types/react 18.3.1 → 19.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
react/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: Fri, 26 Apr 2024 21:06:49 GMT
12
- * Dependencies: [@types/prop-types](https://npmjs.com/package/@types/prop-types), [csstype](https://npmjs.com/package/csstype)
11
+ * Last updated: Wed, 01 Oct 2025 22:02:19 GMT
12
+ * Dependencies: [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), [Dmitry Semigradsky](https://github.com/Semigradsky), and [Matt Pocock](https://github.com/mattpocock).
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), [Priyanshu Rav](https://github.com/priyanshurav), [Dmitry Semigradsky](https://github.com/Semigradsky), and [Matt Pocock](https://github.com/mattpocock).
react/canary.d.ts CHANGED
@@ -31,133 +31,5 @@ declare const UNDEFINED_VOID_ONLY: unique symbol;
31
31
  type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
32
32
 
33
33
  declare module "." {
34
- interface ThenableImpl<T> {
35
- then(onFulfill: (value: T) => unknown, onReject: (error: unknown) => unknown): void | PromiseLike<unknown>;
36
- }
37
- interface UntrackedThenable<T> extends ThenableImpl<T> {
38
- status?: void;
39
- }
40
-
41
- export interface PendingThenable<T> extends ThenableImpl<T> {
42
- status: "pending";
43
- }
44
-
45
- export interface FulfilledThenable<T> extends ThenableImpl<T> {
46
- status: "fulfilled";
47
- value: T;
48
- }
49
-
50
- export interface RejectedThenable<T> extends ThenableImpl<T> {
51
- status: "rejected";
52
- reason: unknown;
53
- }
54
-
55
- export type Thenable<T> = UntrackedThenable<T> | PendingThenable<T> | FulfilledThenable<T> | RejectedThenable<T>;
56
-
57
- export type Usable<T> = Thenable<T> | Context<T>;
58
-
59
- export function use<T>(usable: Usable<T>): T;
60
-
61
- interface ServerContextJSONArray extends ReadonlyArray<ServerContextJSONValue> {}
62
- export type ServerContextJSONValue =
63
- | string
64
- | boolean
65
- | number
66
- | null
67
- | ServerContextJSONArray
68
- | { [key: string]: ServerContextJSONValue };
69
- export interface ServerContext<T extends ServerContextJSONValue> {
70
- Provider: Provider<T>;
71
- }
72
- /**
73
- * Accepts a context object (the value returned from `React.createContext` or `React.createServerContext`) and returns the current
74
- * context value, as given by the nearest context provider for the given context.
75
- *
76
- * @version 16.8.0
77
- * @see https://react.dev/reference/react/useContext
78
- */
79
- function useContext<T extends ServerContextJSONValue>(context: ServerContext<T>): T;
80
- export function createServerContext<T extends ServerContextJSONValue>(
81
- globalName: string,
82
- defaultValue: T,
83
- ): ServerContext<T>;
84
-
85
- // eslint-disable-next-line @typescript-eslint/ban-types
86
- export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
87
-
88
34
  export function unstable_useCacheRefresh(): () => void;
89
-
90
- interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {
91
- functions: (formData: FormData) => void;
92
- }
93
-
94
- export interface TransitionStartFunction {
95
- /**
96
- * Marks all state updates inside the async function as transitions
97
- *
98
- * @see {https://react.dev/reference/react/useTransition#starttransition}
99
- *
100
- * @param callback
101
- */
102
- (callback: () => Promise<VoidOrUndefinedOnly>): void;
103
- }
104
-
105
- /**
106
- * Similar to `useTransition` but allows uses where hooks are not available.
107
- *
108
- * @param callback An _asynchronous_ function which causes state updates that can be deferred.
109
- */
110
- export function startTransition(scope: () => Promise<VoidOrUndefinedOnly>): void;
111
-
112
- export function useOptimistic<State>(
113
- passthrough: State,
114
- ): [State, (action: State | ((pendingState: State) => State)) => void];
115
- export function useOptimistic<State, Action>(
116
- passthrough: State,
117
- reducer: (state: State, action: Action) => State,
118
- ): [State, (action: Action) => void];
119
-
120
- interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
121
- cleanup: () => VoidOrUndefinedOnly;
122
- }
123
-
124
- export function useActionState<State>(
125
- action: (state: Awaited<State>) => State | Promise<State>,
126
- initialState: Awaited<State>,
127
- permalink?: string,
128
- ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
129
- export function useActionState<State, Payload>(
130
- action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
131
- initialState: Awaited<State>,
132
- permalink?: string,
133
- ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
134
-
135
- interface DOMAttributes<T> {
136
- // Transition Events
137
- onTransitionCancel?: TransitionEventHandler<T> | undefined;
138
- onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
139
- onTransitionRun?: TransitionEventHandler<T> | undefined;
140
- onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
141
- onTransitionStart?: TransitionEventHandler<T> | undefined;
142
- onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
143
- }
144
-
145
- /**
146
- * @internal Use `Awaited<ReactNode>` instead
147
- */
148
- // Helper type to enable `Awaited<ReactNode>`.
149
- // Must be a copy of the non-thenables of `ReactNode`.
150
- type AwaitedReactNode =
151
- | ReactElement
152
- | string
153
- | number
154
- | Iterable<AwaitedReactNode>
155
- | ReactPortal
156
- | boolean
157
- | null
158
- | undefined;
159
- interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {
160
- promises: Promise<AwaitedReactNode>;
161
- bigints: bigint;
162
- }
163
35
  }
@@ -0,0 +1,4 @@
1
+ // Not meant to be used directly
2
+ // Omitting all exports so that they don't appear in IDE autocomplete.
3
+
4
+ export {};
react/experimental.d.ts CHANGED
@@ -51,10 +51,13 @@ declare module "." {
51
51
  unstable_expectedLoadTime?: number | undefined;
52
52
  }
53
53
 
54
- export type SuspenseListRevealOrder = "forwards" | "backwards" | "together";
55
- export type SuspenseListTailMode = "collapsed" | "hidden";
54
+ export type SuspenseListRevealOrder = "forwards" | "backwards" | "together" | "independent";
55
+ export type SuspenseListTailMode = "collapsed" | "hidden" | "visible";
56
56
 
57
57
  export interface SuspenseListCommonProps {
58
+ }
59
+
60
+ interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
58
61
  /**
59
62
  * Note that SuspenseList require more than one child;
60
63
  * it is a runtime warning to provide only a single child.
@@ -62,33 +65,32 @@ declare module "." {
62
65
  * It does, however, allow those children to be wrapped inside a single
63
66
  * level of `<React.Fragment>`.
64
67
  */
65
- children: ReactElement | Iterable<ReactElement>;
66
- }
67
-
68
- interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
68
+ children: Iterable<ReactElement> | AsyncIterable<ReactElement>;
69
69
  /**
70
70
  * Defines the order in which the `SuspenseList` children should be revealed.
71
71
  */
72
- revealOrder: "forwards" | "backwards";
72
+ revealOrder: "forwards" | "backwards" | "unstable_legacy-backwards";
73
73
  /**
74
74
  * Dictates how unloaded items in a SuspenseList is shown.
75
75
  *
76
76
  * - By default, `SuspenseList` will show all fallbacks in the list.
77
77
  * - `collapsed` shows only the next fallback in the list.
78
- * - `hidden` doesnt show any unloaded items.
78
+ * - `hidden` doesn't show any unloaded items.
79
+ * - `visible` shows all fallbacks in the list.
79
80
  */
80
- tail?: SuspenseListTailMode | undefined;
81
+ tail: SuspenseListTailMode;
81
82
  }
82
83
 
83
84
  interface NonDirectionalSuspenseListProps extends SuspenseListCommonProps {
85
+ children: ReactNode;
84
86
  /**
85
87
  * Defines the order in which the `SuspenseList` children should be revealed.
86
88
  */
87
- revealOrder?: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps["revealOrder"]> | undefined;
89
+ revealOrder: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps["revealOrder"]> | undefined;
88
90
  /**
89
91
  * The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
90
92
  */
91
- tail?: never | undefined;
93
+ tail?: never;
92
94
  }
93
95
 
94
96
  export type SuspenseListProps = DirectionalSuspenseListProps | NonDirectionalSuspenseListProps;
@@ -106,9 +108,6 @@ declare module "." {
106
108
  */
107
109
  export const unstable_SuspenseList: ExoticComponent<SuspenseListProps>;
108
110
 
109
- // eslint-disable-next-line @typescript-eslint/ban-types
110
- export function experimental_useEffectEvent<T extends Function>(event: T): T;
111
-
112
111
  type Reference = object;
113
112
  type TaintableUniqueValue = string | bigint | ArrayBufferView;
114
113
  function experimental_taintUniqueValue(
@@ -118,10 +117,109 @@ declare module "." {
118
117
  ): void;
119
118
  function experimental_taintObjectReference(message: string | undefined, object: Reference): void;
120
119
 
121
- export interface HTMLAttributes<T> {
120
+ export interface ViewTransitionInstance {
121
+ /**
122
+ * The {@link ViewTransitionProps name} that was used in the corresponding {@link ViewTransition} component or `"auto"` if the `name` prop was omitted.
123
+ */
124
+ name: string;
125
+ }
126
+
127
+ export type ViewTransitionClassPerType = Record<"default" | (string & {}), "none" | "auto" | (string & {})>;
128
+ export type ViewTransitionClass = ViewTransitionClassPerType | ViewTransitionClassPerType[string];
129
+
130
+ export interface ViewTransitionProps {
131
+ children?: ReactNode | undefined;
132
+ /**
133
+ * Assigns the {@link https://developer.chrome.com/blog/view-transitions-update-io24#view-transition-class `view-transition-class`} class to the underlying DOM node.
134
+ */
135
+ default?: ViewTransitionClass | undefined;
136
+ /**
137
+ * Combined with {@link className} if this `<ViewTransition>` or its parent Component is mounted and there's no other with the same name being deleted.
138
+ * `"none"` is a special value that deactivates the view transition name under that condition.
139
+ */
140
+ enter?: ViewTransitionClass | undefined;
141
+ /**
142
+ * Combined with {@link className} if this `<ViewTransition>` or its parent Component is unmounted and there's no other with the same name being deleted.
143
+ * `"none"` is a special value that deactivates the view transition name under that condition.
144
+ */
145
+ exit?: ViewTransitionClass | undefined;
146
+ /**
147
+ * "auto" will automatically assign a view-transition-name to the inner DOM node.
148
+ * That way you can add a View Transition to a Component without controlling its DOM nodes styling otherwise.
149
+ *
150
+ * A difference between this and the browser's built-in view-transition-name: auto is that switching the DOM nodes within the `<ViewTransition>` component preserves the same name so this example cross-fades between the DOM nodes instead of causing an exit and enter.
151
+ * @default "auto"
152
+ */
153
+ name?: "auto" | (string & {}) | undefined;
154
+ /**
155
+ * The `<ViewTransition>` or its parent Component is mounted and there's no other `<ViewTransition>` with the same name being deleted.
156
+ */
157
+ onEnter?: (instance: ViewTransitionInstance, types: Array<string>) => void;
122
158
  /**
123
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
159
+ * The `<ViewTransition>` or its parent Component is unmounted and there's no other `<ViewTransition>` with the same name being deleted.
124
160
  */
125
- inert?: boolean | undefined;
161
+ onExit?: (instance: ViewTransitionInstance, types: Array<string>) => void;
162
+ /**
163
+ * This `<ViewTransition>` is being mounted and another `<ViewTransition>` instance with the same name is being unmounted elsewhere.
164
+ */
165
+ onShare?: (instance: ViewTransitionInstance, types: Array<string>) => void;
166
+ /**
167
+ * The content of `<ViewTransition>` has changed either due to DOM mutations or because an inner child `<ViewTransition>` has resized.
168
+ */
169
+ onUpdate?: (instance: ViewTransitionInstance, types: Array<string>) => void;
170
+ ref?: Ref<ViewTransitionInstance> | undefined;
171
+ /**
172
+ * Combined with {@link className} if this `<ViewTransition>` is being mounted and another instance with the same name is being unmounted elsewhere.
173
+ * `"none"` is a special value that deactivates the view transition name under that condition.
174
+ */
175
+ share?: ViewTransitionClass | undefined;
176
+ /**
177
+ * Combined with {@link className} if the content of this `<ViewTransition>` has changed either due to DOM mutations or because an inner child has resized.
178
+ * `"none"` is a special value that deactivates the view transition name under that condition.
179
+ */
180
+ update?: ViewTransitionClass | undefined;
181
+ }
182
+
183
+ /**
184
+ * Opt-in for using {@link https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API View Transitions} in React.
185
+ * View Transitions only trigger for async updates like {@link startTransition}, {@link useDeferredValue}, Actions or <{@link Suspense}> revealing from fallback to content.
186
+ * Synchronous updates provide an opt-out but also guarantee that they commit immediately which View Transitions can't.
187
+ *
188
+ * @see {@link https://github.com/facebook/react/pull/31975}
189
+ */
190
+ export const unstable_ViewTransition: ExoticComponent<ViewTransitionProps>;
191
+
192
+ export function unstable_addTransitionType(type: string): void;
193
+
194
+ // @enableGestureTransition
195
+ // Implemented by the specific renderer e.g. `react-dom`.
196
+ // Keep in mind that augmented interfaces merge their JSDoc so if you put
197
+ // JSDoc here and in the renderer, the IDE will display both.
198
+ export interface GestureProvider {}
199
+ export interface GestureOptions {
200
+ rangeStart?: number | undefined;
201
+ rangeEnd?: number | undefined;
202
+ }
203
+ /** */
204
+ export function unstable_startGestureTransition(
205
+ provider: GestureProvider,
206
+ scope: () => void,
207
+ options?: GestureOptions,
208
+ ): () => void;
209
+
210
+ // @enableFragmentRefs
211
+ export interface FragmentInstance {}
212
+
213
+ export interface FragmentProps {
214
+ ref?: Ref<FragmentInstance> | undefined;
215
+ }
216
+
217
+ // @enableSrcObject
218
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_IMG_SRC_TYPES {
219
+ srcObject: Blob;
220
+ }
221
+
222
+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {
223
+ srcObject: Blob | MediaSource | MediaStream;
126
224
  }
127
225
  }
react/global.d.ts CHANGED
@@ -13,10 +13,12 @@ interface ClipboardEvent extends Event {}
13
13
  interface CompositionEvent extends Event {}
14
14
  interface DragEvent extends Event {}
15
15
  interface FocusEvent extends Event {}
16
+ interface InputEvent extends Event {}
16
17
  interface KeyboardEvent extends Event {}
17
18
  interface MouseEvent extends Event {}
18
19
  interface TouchEvent extends Event {}
19
20
  interface PointerEvent extends Event {}
21
+ interface ToggleEvent extends Event {}
20
22
  interface TransitionEvent extends Event {}
21
23
  interface UIEvent extends Event {}
22
24
  interface WheelEvent extends Event {}
@@ -157,3 +159,7 @@ interface WebGLRenderingContext {}
157
159
  interface WebGL2RenderingContext {}
158
160
 
159
161
  interface TrustedHTML {}
162
+
163
+ interface Blob {}
164
+ interface MediaStream {}
165
+ interface MediaSource {}