@types/react-dom 18.3.0 → 19.1.7

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-dom/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
  > `npm install --save @types/react-dom`
3
3
 
4
4
  # Summary
5
- This package contains type definitions for react-dom (https://reactjs.org).
5
+ This package contains type definitions for react-dom (https://react.dev/).
6
6
 
7
7
  # Details
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Thu, 25 Apr 2024 20:07:03 GMT
12
- * Dependencies: [@types/react](https://npmjs.com/package/@types/react)
11
+ * Last updated: Tue, 29 Jul 2025 09:39:53 GMT
12
+ * Dependencies: none
13
+ * Peer dependencies: [@types/react](https://npmjs.com/package/@types/react)
13
14
 
14
15
  # Credits
15
16
  These definitions were written by [Asana](https://asana.com), [AssureSign](http://www.assuresign.com), [Microsoft](https://microsoft.com), [MartynasZilinskas](https://github.com/MartynasZilinskas), [Josh Rutherford](https://github.com/theruther4d), [Jessica Franco](https://github.com/Jessidhia), and [Sebastian Silbermann](https://github.com/eps1lon).
react-dom/canary.d.ts CHANGED
@@ -31,154 +31,7 @@ import ReactDOM = require(".");
31
31
 
32
32
  export {};
33
33
 
34
- declare const REACT_FORM_STATE_SIGIL: unique symbol;
35
-
36
- declare module "." {
37
- function prefetchDNS(href: string): void;
38
-
39
- interface PreconnectOptions {
40
- // Don't create a helper type.
41
- // It would have to be in module scope to be inlined in TS tooltips.
42
- // But then it becomes part of the public API.
43
- // TODO: Upstream to microsoft/TypeScript-DOM-lib-generator -> w3c/webref
44
- // since the spec has a notion of a dedicated type: https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attribute
45
- crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
46
- }
47
- function preconnect(href: string, options?: PreconnectOptions): void;
48
-
49
- type PreloadAs =
50
- | "audio"
51
- | "document"
52
- | "embed"
53
- | "fetch"
54
- | "font"
55
- | "image"
56
- | "object"
57
- | "track"
58
- | "script"
59
- | "style"
60
- | "video"
61
- | "worker";
62
- interface PreloadOptions {
63
- as: PreloadAs;
64
- crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
65
- fetchPriority?: "high" | "low" | "auto" | undefined;
66
- // TODO: These should only be allowed with `as: 'image'` but it's not trivial to write tests against the full TS support matrix.
67
- imageSizes?: string | undefined;
68
- imageSrcSet?: string | undefined;
69
- integrity?: string | undefined;
70
- type?: string | undefined;
71
- nonce?: string | undefined;
72
- referrerPolicy?: ReferrerPolicy | undefined;
73
- }
74
- function preload(href: string, options?: PreloadOptions): void;
75
-
76
- // https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
77
- type PreloadModuleAs = RequestDestination;
78
- interface PreloadModuleOptions {
79
- /**
80
- * @default "script"
81
- */
82
- as: PreloadModuleAs;
83
- crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
84
- integrity?: string | undefined;
85
- nonce?: string | undefined;
86
- }
87
- function preloadModule(href: string, options?: PreloadModuleOptions): void;
88
-
89
- type PreinitAs = "script" | "style";
90
- interface PreinitOptions {
91
- as: PreinitAs;
92
- crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
93
- fetchPriority?: "high" | "low" | "auto" | undefined;
94
- precedence?: string | undefined;
95
- integrity?: string | undefined;
96
- nonce?: string | undefined;
97
- }
98
- function preinit(href: string, options?: PreinitOptions): void;
99
-
100
- // Will be expanded to include all of https://github.com/tc39/proposal-import-attributes
101
- type PreinitModuleAs = "script";
102
- interface PreinitModuleOptions {
103
- /**
104
- * @default "script"
105
- */
106
- as?: PreinitModuleAs;
107
- crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
108
- integrity?: string | undefined;
109
- nonce?: string | undefined;
110
- }
111
- function preinitModule(href: string, options?: PreinitModuleOptions): void;
112
-
113
- interface FormStatusNotPending {
114
- pending: false;
115
- data: null;
116
- method: null;
117
- action: null;
118
- }
119
-
120
- interface FormStatusPending {
121
- pending: true;
122
- data: FormData;
123
- method: string;
124
- action: string | ((formData: FormData) => void | Promise<void>);
125
- }
126
-
127
- type FormStatus = FormStatusPending | FormStatusNotPending;
128
-
129
- function useFormStatus(): FormStatus;
130
-
131
- function useFormState<State>(
132
- action: (state: Awaited<State>) => State | Promise<State>,
133
- initialState: Awaited<State>,
134
- permalink?: string,
135
- ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
136
- function useFormState<State, Payload>(
137
- action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
138
- initialState: Awaited<State>,
139
- permalink?: string,
140
- ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
141
-
142
- function requestFormReset(form: HTMLFormElement): void;
143
- }
144
-
145
- declare module "./client" {
146
- interface ReactFormState {
147
- [REACT_FORM_STATE_SIGIL]: never;
148
- }
149
-
150
- interface RootOptions {
151
- onUncaughtError?:
152
- | ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
153
- | undefined;
154
- onCaughtError?:
155
- | ((
156
- error: unknown,
157
- errorInfo: {
158
- componentStack?: string | undefined;
159
- errorBoundary?: React.Component<unknown> | undefined;
160
- },
161
- ) => void)
162
- | undefined;
163
- }
164
-
165
- interface HydrationOptions {
166
- formState?: ReactFormState | null;
167
- onUncaughtError?:
168
- | ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
169
- | undefined;
170
- onCaughtError?:
171
- | ((
172
- error: unknown,
173
- errorInfo: {
174
- componentStack?: string | undefined;
175
- errorBoundary?: React.Component<unknown> | undefined;
176
- },
177
- ) => void)
178
- | undefined;
179
- }
180
-
181
- interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAINERS {
182
- document: Document;
183
- }
34
+ declare module "react" {
35
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
36
+ interface CacheSignal extends AbortSignal {}
184
37
  }
react-dom/client.d.ts CHANGED
@@ -5,12 +5,33 @@
5
5
  // See https://github.com/facebook/react/blob/main/packages/react-dom/client.js to see how the exports are declared,
6
6
 
7
7
  import React = require("react");
8
+
9
+ export {};
10
+
11
+ declare const REACT_FORM_STATE_SIGIL: unique symbol;
12
+ export interface ReactFormState {
13
+ [REACT_FORM_STATE_SIGIL]: never;
14
+ }
15
+
8
16
  export interface HydrationOptions {
17
+ formState?: ReactFormState | null;
9
18
  /**
10
19
  * Prefix for `useId`.
11
20
  */
12
21
  identifierPrefix?: string;
22
+ onUncaughtError?:
23
+ | ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
24
+ | undefined;
13
25
  onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
26
+ onCaughtError?:
27
+ | ((
28
+ error: unknown,
29
+ errorInfo: {
30
+ componentStack?: string | undefined;
31
+ errorBoundary?: React.Component<unknown> | undefined;
32
+ },
33
+ ) => void)
34
+ | undefined;
14
35
  }
15
36
 
16
37
  export interface RootOptions {
@@ -18,11 +39,22 @@ export interface RootOptions {
18
39
  * Prefix for `useId`.
19
40
  */
20
41
  identifierPrefix?: string;
42
+ onUncaughtError?:
43
+ | ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
44
+ | undefined;
21
45
  onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
46
+ onCaughtError?:
47
+ | ((
48
+ error: unknown,
49
+ errorInfo: {
50
+ componentStack?: string | undefined;
51
+ errorBoundary?: React.Component<unknown> | undefined;
52
+ },
53
+ ) => void)
54
+ | undefined;
22
55
  }
23
56
 
24
57
  export interface ErrorInfo {
25
- digest?: string;
26
58
  componentStack?: string;
27
59
  }
28
60
 
@@ -41,6 +73,7 @@ export interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAI
41
73
  export type Container =
42
74
  | Element
43
75
  | DocumentFragment
76
+ | Document
44
77
  | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAINERS[
45
78
  keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAINERS
46
79
  ];
@@ -32,5 +32,55 @@ import ReactDOM = require("./canary");
32
32
 
33
33
  export {};
34
34
 
35
+ declare const UNDEFINED_VOID_ONLY: unique symbol;
36
+ type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
37
+
35
38
  declare module "." {
36
39
  }
40
+
41
+ declare module "react" {
42
+ interface ViewTransitionPseudoElement extends Animatable {
43
+ getComputedStyle: () => CSSStyleDeclaration;
44
+ }
45
+
46
+ interface ViewTransitionInstance {
47
+ group: ViewTransitionPseudoElement;
48
+ imagePair: ViewTransitionPseudoElement;
49
+ old: ViewTransitionPseudoElement;
50
+ new: ViewTransitionPseudoElement;
51
+ }
52
+
53
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
54
+ interface GestureProvider extends AnimationTimeline {}
55
+
56
+ // @enableFragmentRefs
57
+ interface FragmentInstance {
58
+ blur: () => void;
59
+ focus: (focusOptions?: FocusOptions | undefined) => void;
60
+ focusLast: (focusOptions?: FocusOptions | undefined) => void;
61
+ observeUsing(observer: IntersectionObserver | ResizeObserver): void;
62
+ unobserveUsing(observer: IntersectionObserver | ResizeObserver): void;
63
+ getClientRects(): Array<DOMRect>;
64
+ getRootNode(getRootNodeOptions?: GetRootNodeOptions | undefined): Document | ShadowRoot | FragmentInstance;
65
+ addEventListener(
66
+ type: string,
67
+ listener: EventListener,
68
+ optionsOrUseCapture?: Parameters<Element["addEventListener"]>[2],
69
+ ): void;
70
+ removeEventListener(
71
+ type: string,
72
+ listener: EventListener,
73
+ optionsOrUseCapture?: Parameters<Element["removeEventListener"]>[2],
74
+ ): void;
75
+ }
76
+ }
77
+
78
+ declare module "./client" {
79
+ type TransitionIndicatorCleanup = () => VoidOrUndefinedOnly;
80
+ interface RootOptions {
81
+ onDefaultTransitionIndicator?: (() => void | TransitionIndicatorCleanup) | undefined;
82
+ }
83
+ interface HydrationOptions {
84
+ onDefaultTransitionIndicator?: (() => void | TransitionIndicatorCleanup) | undefined;
85
+ }
86
+ }
react-dom/index.d.ts CHANGED
@@ -4,146 +4,125 @@
4
4
 
5
5
  export as namespace ReactDOM;
6
6
 
7
- import {
8
- CElement,
9
- Component,
10
- ComponentState,
11
- DOMAttributes,
12
- DOMElement,
13
- FunctionComponentElement,
14
- ReactElement,
15
- ReactInstance,
16
- ReactNode,
17
- ReactPortal,
18
- } from "react";
19
-
20
- /**
21
- * @deprecated See https://react.dev/reference/react-dom/findDOMNode#alternatives
22
- */
23
- export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
24
- /**
25
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
26
- */
27
- export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
7
+ import { Key, ReactNode, ReactPortal } from "react";
28
8
 
29
9
  export function createPortal(
30
10
  children: ReactNode,
31
11
  container: Element | DocumentFragment,
32
- key?: null | string,
12
+ key?: Key | null,
33
13
  ): ReactPortal;
34
14
 
35
15
  export const version: string;
36
- /**
37
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
38
- */
39
- export const render: Renderer;
40
- /**
41
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
42
- */
43
- export const hydrate: Renderer;
44
16
 
45
17
  export function flushSync<R>(fn: () => R): R;
46
18
 
47
19
  export function unstable_batchedUpdates<A, R>(callback: (a: A) => R, a: A): R;
48
20
  export function unstable_batchedUpdates<R>(callback: () => R): R;
49
21
 
50
- /**
51
- * @deprecated
52
- */
53
- export function unstable_renderSubtreeIntoContainer<T extends Element>(
54
- parentComponent: Component<any>,
55
- element: DOMElement<DOMAttributes<T>, T>,
56
- container: Element,
57
- callback?: (element: T) => any,
58
- ): T;
59
- /**
60
- * @deprecated
61
- */
62
- export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
63
- parentComponent: Component<any>,
64
- element: CElement<P, T>,
65
- container: Element,
66
- callback?: (component: T) => any,
67
- ): T;
68
- /**
69
- * @deprecated
70
- */
71
- export function unstable_renderSubtreeIntoContainer<P>(
72
- parentComponent: Component<any>,
73
- element: ReactElement<P>,
74
- container: Element,
75
- callback?: (component?: Component<P, ComponentState> | Element) => any,
76
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
77
- ): Component<P, ComponentState> | Element | void;
78
-
79
- export type Container = Element | Document | DocumentFragment;
80
-
81
- export interface Renderer {
82
- // Deprecated(render): The return value is deprecated.
83
- // In future releases the render function's return type will be void.
84
-
85
- /**
86
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
87
- */
88
- <T extends Element>(
89
- element: DOMElement<DOMAttributes<T>, T>,
90
- container: Container | null,
91
- callback?: () => void,
92
- ): T;
93
-
94
- /**
95
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
96
- */
97
- (
98
- element: Array<DOMElement<DOMAttributes<any>, any>>,
99
- container: Container | null,
100
- callback?: () => void,
101
- ): Element;
102
-
103
- /**
104
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
105
- */
106
- (
107
- element: FunctionComponentElement<any> | Array<FunctionComponentElement<any>>,
108
- container: Container | null,
109
- callback?: () => void,
110
- ): void;
22
+ export interface FormStatusNotPending {
23
+ pending: false;
24
+ data: null;
25
+ method: null;
26
+ action: null;
27
+ }
111
28
 
112
- /**
113
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
114
- */
115
- <P, T extends Component<P, ComponentState>>(
116
- element: CElement<P, T>,
117
- container: Container | null,
118
- callback?: () => void,
119
- ): T;
29
+ export interface FormStatusPending {
30
+ pending: true;
31
+ data: FormData;
32
+ method: string;
33
+ action: string | ((formData: FormData) => void | Promise<void>);
34
+ }
120
35
 
121
- /**
122
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
123
- */
124
- (
125
- element: Array<CElement<any, Component<any, ComponentState>>>,
126
- container: Container | null,
127
- callback?: () => void,
128
- ): Component<any, ComponentState>;
36
+ export type FormStatus = FormStatusPending | FormStatusNotPending;
37
+
38
+ export function useFormStatus(): FormStatus;
39
+
40
+ export function useFormState<State>(
41
+ action: (state: Awaited<State>) => State | Promise<State>,
42
+ initialState: Awaited<State>,
43
+ permalink?: string,
44
+ ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
45
+ export function useFormState<State, Payload>(
46
+ action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
47
+ initialState: Awaited<State>,
48
+ permalink?: string,
49
+ ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
50
+
51
+ export function prefetchDNS(href: string): void;
52
+
53
+ export interface PreconnectOptions {
54
+ // Don't create a helper type.
55
+ // It would have to be in module scope to be inlined in TS tooltips.
56
+ // But then it becomes part of the public API.
57
+ // TODO: Upstream to microsoft/TypeScript-DOM-lib-generator -> w3c/webref
58
+ // since the spec has a notion of a dedicated type: https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attribute
59
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
60
+ }
61
+ export function preconnect(href: string, options?: PreconnectOptions): void;
62
+
63
+ export type PreloadAs =
64
+ | "audio"
65
+ | "document"
66
+ | "embed"
67
+ | "fetch"
68
+ | "font"
69
+ | "image"
70
+ | "object"
71
+ | "track"
72
+ | "script"
73
+ | "style"
74
+ | "video"
75
+ | "worker";
76
+ export interface PreloadOptions {
77
+ as: PreloadAs;
78
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
79
+ fetchPriority?: "high" | "low" | "auto" | undefined;
80
+ // TODO: These should only be allowed with `as: 'image'` but it's not trivial to write tests against the full TS support matrix.
81
+ imageSizes?: string | undefined;
82
+ imageSrcSet?: string | undefined;
83
+ integrity?: string | undefined;
84
+ type?: string | undefined;
85
+ nonce?: string | undefined;
86
+ referrerPolicy?: ReferrerPolicy | undefined;
87
+ media?: string | undefined;
88
+ }
89
+ export function preload(href: string, options?: PreloadOptions): void;
129
90
 
91
+ // https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
92
+ export type PreloadModuleAs = RequestDestination;
93
+ export interface PreloadModuleOptions {
130
94
  /**
131
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
95
+ * @default "script"
132
96
  */
133
- <P>(
134
- element: ReactElement<P>,
135
- container: Container | null,
136
- callback?: () => void,
137
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
138
- ): Component<P, ComponentState> | Element | void;
97
+ as: PreloadModuleAs;
98
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
99
+ integrity?: string | undefined;
100
+ nonce?: string | undefined;
101
+ }
102
+ export function preloadModule(href: string, options?: PreloadModuleOptions): void;
103
+
104
+ export type PreinitAs = "script" | "style";
105
+ export interface PreinitOptions {
106
+ as: PreinitAs;
107
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
108
+ fetchPriority?: "high" | "low" | "auto" | undefined;
109
+ precedence?: string | undefined;
110
+ integrity?: string | undefined;
111
+ nonce?: string | undefined;
112
+ }
113
+ export function preinit(href: string, options?: PreinitOptions): void;
139
114
 
115
+ // Will be expanded to include all of https://github.com/tc39/proposal-import-attributes
116
+ export type PreinitModuleAs = "script";
117
+ export interface PreinitModuleOptions {
140
118
  /**
141
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
119
+ * @default "script"
142
120
  */
143
- (
144
- element: ReactElement[],
145
- container: Container | null,
146
- callback?: () => void,
147
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
148
- ): Component<any, ComponentState> | Element | void;
121
+ as?: PreinitModuleAs;
122
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
123
+ integrity?: string | undefined;
124
+ nonce?: string | undefined;
149
125
  }
126
+ export function preinitModule(href: string, options?: PreinitModuleOptions): void;
127
+
128
+ export function requestFormReset(form: HTMLFormElement): void;
react-dom/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react-dom",
3
- "version": "18.3.0",
3
+ "version": "19.1.7",
4
4
  "description": "TypeScript definitions for react-dom",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom",
6
6
  "license": "MIT",
@@ -61,6 +61,46 @@
61
61
  "default": "./server.d.ts"
62
62
  }
63
63
  },
64
+ "./server.browser": {
65
+ "types": {
66
+ "default": "./server.browser.d.ts"
67
+ }
68
+ },
69
+ "./server.bun": {
70
+ "types": {
71
+ "default": "./server.bun.d.ts"
72
+ }
73
+ },
74
+ "./server.edge": {
75
+ "types": {
76
+ "default": "./server.edge.d.ts"
77
+ }
78
+ },
79
+ "./server.node": {
80
+ "types": {
81
+ "default": "./server.node.d.ts"
82
+ }
83
+ },
84
+ "./static": {
85
+ "types": {
86
+ "default": "./static.d.ts"
87
+ }
88
+ },
89
+ "./static.browser": {
90
+ "types": {
91
+ "default": "./static.browser.d.ts"
92
+ }
93
+ },
94
+ "./static.edge": {
95
+ "types": {
96
+ "default": "./static.edge.d.ts"
97
+ }
98
+ },
99
+ "./static.node": {
100
+ "types": {
101
+ "default": "./static.node.d.ts"
102
+ }
103
+ },
64
104
  "./experimental": {
65
105
  "types": {
66
106
  "default": "./experimental.d.ts"
@@ -79,9 +119,10 @@
79
119
  "directory": "types/react-dom"
80
120
  },
81
121
  "scripts": {},
82
- "dependencies": {
83
- "@types/react": "*"
122
+ "dependencies": {},
123
+ "peerDependencies": {
124
+ "@types/react": "^19.0.0"
84
125
  },
85
- "typesPublisherContentHash": "6e701783391e040466f55ff67d4efe35c3cbc5868b0a0937f1dfb8f63fce36fc",
86
- "typeScriptVersion": "4.7"
126
+ "typesPublisherContentHash": "75cb554bdc8192cf72b61d4f3e8a05c51ba6df48b5fdb7154edfa345830d060b",
127
+ "typeScriptVersion": "5.1"
87
128
  }
@@ -0,0 +1 @@
1
+ export { renderToReadableStream, renderToStaticMarkup, renderToString } from "./server";
@@ -0,0 +1 @@
1
+ export { renderToReadableStream, renderToStaticMarkup, renderToString } from "./server";
react-dom/server.d.ts CHANGED
@@ -24,13 +24,19 @@ declare global {
24
24
  import { ReactNode } from "react";
25
25
  import { ErrorInfo } from "./client";
26
26
 
27
+ export type BootstrapScriptDescriptor = {
28
+ src: string;
29
+ integrity?: string | undefined;
30
+ crossOrigin?: string | undefined;
31
+ };
32
+
27
33
  export interface RenderToPipeableStreamOptions {
28
34
  identifierPrefix?: string;
29
35
  namespaceURI?: string;
30
36
  nonce?: string;
31
37
  bootstrapScriptContent?: string;
32
- bootstrapScripts?: string[];
33
- bootstrapModules?: string[];
38
+ bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
39
+ bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
34
40
  progressiveChunkSize?: number;
35
41
  onShellReady?: () => void;
36
42
  onShellError?: (error: unknown) => void;
@@ -69,15 +75,6 @@ export function renderToPipeableStream(children: ReactNode, options?: RenderToPi
69
75
  */
70
76
  export function renderToString(element: ReactNode, options?: ServerOptions): string;
71
77
 
72
- /**
73
- * Render a React element to its initial HTML. Returns a Readable stream that outputs
74
- * an HTML string. The HTML output by this stream is exactly equal to what
75
- * `ReactDOMServer.renderToString()` would return.
76
- *
77
- * @deprecated
78
- */
79
- export function renderToNodeStream(element: ReactNode, options?: ServerOptions): NodeJS.ReadableStream;
80
-
81
78
  /**
82
79
  * Similar to `renderToString`, except this doesn't create extra DOM attributes
83
80
  * such as `data-reactid`, that React uses internally. This is useful if you want
@@ -86,22 +83,13 @@ export function renderToNodeStream(element: ReactNode, options?: ServerOptions):
86
83
  */
87
84
  export function renderToStaticMarkup(element: ReactNode, options?: ServerOptions): string;
88
85
 
89
- /**
90
- * Similar to `renderToNodeStream`, except this doesn't create extra DOM attributes
91
- * such as `data-reactid`, that React uses internally. The HTML output by this stream
92
- * is exactly equal to what `ReactDOMServer.renderToStaticMarkup()` would return.
93
- *
94
- * @deprecated
95
- */
96
- export function renderToStaticNodeStream(element: ReactNode, options?: ServerOptions): NodeJS.ReadableStream;
97
-
98
86
  export interface RenderToReadableStreamOptions {
99
87
  identifierPrefix?: string;
100
88
  namespaceURI?: string;
101
89
  nonce?: string;
102
90
  bootstrapScriptContent?: string;
103
- bootstrapScripts?: string[];
104
- bootstrapModules?: string[];
91
+ bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
92
+ bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
105
93
  progressiveChunkSize?: number;
106
94
  signal?: AbortSignal;
107
95
  onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
@@ -0,0 +1 @@
1
+ export { renderToReadableStream, renderToStaticMarkup, renderToString } from "./server";
@@ -0,0 +1 @@
1
+ export { renderToPipeableStream, renderToStaticMarkup, renderToString } from "./server";
@@ -0,0 +1 @@
1
+ export { prerender, version } from "./static";
react-dom/static.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ // forward declarations
2
+ declare global {
3
+ namespace NodeJS {
4
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
5
+ interface ReadableStream {}
6
+ }
7
+
8
+ /**
9
+ * Stub for https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
10
+ */
11
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
12
+ interface AbortSignal {}
13
+
14
+ /**
15
+ * Stub for https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
16
+ */
17
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
18
+ interface ReadableStream<R = any> {}
19
+
20
+ /**
21
+ * Stub for https://developer.mozilla.org/en-US/docs/Web/API/Uint8Array
22
+ */
23
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
24
+ interface Uint8Array {}
25
+ }
26
+
27
+ import { ReactNode } from "react";
28
+ import { ErrorInfo } from "./client";
29
+
30
+ export type BootstrapScriptDescriptor = {
31
+ src: string;
32
+ integrity?: string | undefined;
33
+ crossOrigin?: string | undefined;
34
+ };
35
+
36
+ export interface PrerenderOptions {
37
+ bootstrapScriptContent?: string;
38
+ bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
39
+ bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
40
+ identifierPrefix?: string;
41
+ namespaceURI?: string;
42
+ onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
43
+ progressiveChunkSize?: number;
44
+ signal?: AbortSignal;
45
+ }
46
+
47
+ export interface PrerenderResult {
48
+ prelude: ReadableStream<Uint8Array>;
49
+ }
50
+
51
+ /**
52
+ * Only available in the environments with [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) (this includes browsers, Deno, and some modern edge runtimes).
53
+ *
54
+ * @see [API](https://react.dev/reference/react-dom/static/prerender)
55
+ */
56
+ export function prerender(
57
+ reactNode: ReactNode,
58
+ options?: PrerenderOptions,
59
+ ): Promise<PrerenderResult>;
60
+
61
+ export interface PrerenderToNodeStreamResult {
62
+ prelude: NodeJS.ReadableStream;
63
+ }
64
+
65
+ /**
66
+ * Only available in the environments with [Node.js Streams](https://nodejs.dev/learn/nodejs-streams).
67
+ *
68
+ * @see [API](https://react.dev/reference/react-dom/static/prerenderToNodeStream)
69
+ *
70
+ * @param children
71
+ * @param options
72
+ */
73
+ export function prerenderToNodeStream(
74
+ reactNode: ReactNode,
75
+ options?: PrerenderOptions,
76
+ ): Promise<PrerenderToNodeStreamResult>;
77
+
78
+ export const version: string;
@@ -0,0 +1 @@
1
+ export { prerender, version } from "./static";
@@ -0,0 +1 @@
1
+ export { prerenderToNodeStream, version } from "./static";
@@ -1,402 +1,7 @@
1
- import {
2
- AbstractView,
3
- CElement,
4
- ClassType,
5
- Component,
6
- ComponentClass,
7
- DOMAttributes,
8
- DOMElement,
9
- FC,
10
- FunctionComponentElement,
11
- ReactElement,
12
- ReactHTMLElement,
13
- ReactInstance,
14
- } from "react";
15
-
16
- import * as ReactTestUtils from ".";
17
-
18
1
  export {};
19
2
 
20
- export interface OptionalEventProperties {
21
- bubbles?: boolean | undefined;
22
- cancelable?: boolean | undefined;
23
- currentTarget?: EventTarget | undefined;
24
- defaultPrevented?: boolean | undefined;
25
- eventPhase?: number | undefined;
26
- isTrusted?: boolean | undefined;
27
- nativeEvent?: Event | undefined;
28
- preventDefault?(): void;
29
- stopPropagation?(): void;
30
- target?: EventTarget | undefined;
31
- timeStamp?: Date | undefined;
32
- type?: string | undefined;
33
- }
34
-
35
- export type ModifierKey =
36
- | "Alt"
37
- | "AltGraph"
38
- | "CapsLock"
39
- | "Control"
40
- | "Fn"
41
- | "FnLock"
42
- | "Hyper"
43
- | "Meta"
44
- | "NumLock"
45
- | "ScrollLock"
46
- | "Shift"
47
- | "Super"
48
- | "Symbol"
49
- | "SymbolLock";
50
-
51
- export interface SyntheticEventData extends OptionalEventProperties {
52
- altKey?: boolean | undefined;
53
- button?: number | undefined;
54
- buttons?: number | undefined;
55
- clientX?: number | undefined;
56
- clientY?: number | undefined;
57
- changedTouches?: TouchList | undefined;
58
- charCode?: number | undefined;
59
- clipboardData?: DataTransfer | undefined;
60
- ctrlKey?: boolean | undefined;
61
- deltaMode?: number | undefined;
62
- deltaX?: number | undefined;
63
- deltaY?: number | undefined;
64
- deltaZ?: number | undefined;
65
- detail?: number | undefined;
66
- getModifierState?(key: ModifierKey): boolean;
67
- key?: string | undefined;
68
- keyCode?: number | undefined;
69
- locale?: string | undefined;
70
- location?: number | undefined;
71
- metaKey?: boolean | undefined;
72
- pageX?: number | undefined;
73
- pageY?: number | undefined;
74
- relatedTarget?: EventTarget | undefined;
75
- repeat?: boolean | undefined;
76
- screenX?: number | undefined;
77
- screenY?: number | undefined;
78
- shiftKey?: boolean | undefined;
79
- targetTouches?: TouchList | undefined;
80
- touches?: TouchList | undefined;
81
- view?: AbstractView | undefined;
82
- which?: number | undefined;
83
- }
84
-
85
- export type EventSimulator = (element: Element | Component<any>, eventData?: SyntheticEventData) => void;
86
-
87
- export interface MockedComponentClass {
88
- new(props: any): any;
89
- }
90
-
91
- export interface ShallowRenderer {
92
- /**
93
- * After `shallowRenderer.render()` has been called, returns shallowly rendered output.
94
- */
95
- getRenderOutput<E extends ReactElement>(): E;
3
+ export {
96
4
  /**
97
- * Similar to `ReactDOM.render` but it doesn't require DOM and only renders a single level deep.
98
- */
99
- render(element: ReactElement, context?: any): void;
100
- unmount(): void;
101
- }
102
-
103
- /**
104
- * Simulate an event dispatch on a DOM node with optional `eventData` event data.
105
- * `Simulate` has a method for every event that React understands.
106
- */
107
- export namespace Simulate {
108
- const abort: EventSimulator;
109
- const animationEnd: EventSimulator;
110
- const animationIteration: EventSimulator;
111
- const animationStart: EventSimulator;
112
- const blur: EventSimulator;
113
- const cancel: EventSimulator;
114
- const canPlay: EventSimulator;
115
- const canPlayThrough: EventSimulator;
116
- const change: EventSimulator;
117
- const click: EventSimulator;
118
- const close: EventSimulator;
119
- const compositionEnd: EventSimulator;
120
- const compositionStart: EventSimulator;
121
- const compositionUpdate: EventSimulator;
122
- const contextMenu: EventSimulator;
123
- const copy: EventSimulator;
124
- const cut: EventSimulator;
125
- const auxClick: EventSimulator;
126
- const doubleClick: EventSimulator;
127
- const drag: EventSimulator;
128
- const dragEnd: EventSimulator;
129
- const dragEnter: EventSimulator;
130
- const dragExit: EventSimulator;
131
- const dragLeave: EventSimulator;
132
- const dragOver: EventSimulator;
133
- const dragStart: EventSimulator;
134
- const drop: EventSimulator;
135
- const durationChange: EventSimulator;
136
- const emptied: EventSimulator;
137
- const encrypted: EventSimulator;
138
- const ended: EventSimulator;
139
- const error: EventSimulator;
140
- const focus: EventSimulator;
141
- const input: EventSimulator;
142
- const invalid: EventSimulator;
143
- const keyDown: EventSimulator;
144
- const keyPress: EventSimulator;
145
- const keyUp: EventSimulator;
146
- const load: EventSimulator;
147
- const loadStart: EventSimulator;
148
- const loadedData: EventSimulator;
149
- const loadedMetadata: EventSimulator;
150
- const mouseDown: EventSimulator;
151
- const mouseEnter: EventSimulator;
152
- const mouseLeave: EventSimulator;
153
- const mouseMove: EventSimulator;
154
- const mouseOut: EventSimulator;
155
- const mouseOver: EventSimulator;
156
- const mouseUp: EventSimulator;
157
- const paste: EventSimulator;
158
- const pause: EventSimulator;
159
- const play: EventSimulator;
160
- const playing: EventSimulator;
161
- const progress: EventSimulator;
162
- const pointerCancel: EventSimulator;
163
- const pointerDown: EventSimulator;
164
- const pointerUp: EventSimulator;
165
- const pointerMove: EventSimulator;
166
- const pointerOut: EventSimulator;
167
- const pointerOver: EventSimulator;
168
- const pointerEnter: EventSimulator;
169
- const pointerLeave: EventSimulator;
170
- const gotPointerCapture: EventSimulator;
171
- const lostPointerCapture: EventSimulator;
172
- const rateChange: EventSimulator;
173
- const reset: EventSimulator;
174
- const resize: EventSimulator;
175
- const scroll: EventSimulator;
176
- const toggle: EventSimulator;
177
- const seeked: EventSimulator;
178
- const seeking: EventSimulator;
179
- const select: EventSimulator;
180
- const beforeInput: EventSimulator;
181
- const stalled: EventSimulator;
182
- const submit: EventSimulator;
183
- const suspend: EventSimulator;
184
- const timeUpdate: EventSimulator;
185
- const touchCancel: EventSimulator;
186
- const touchEnd: EventSimulator;
187
- const touchMove: EventSimulator;
188
- const touchStart: EventSimulator;
189
- const transitionEnd: EventSimulator;
190
- const volumeChange: EventSimulator;
191
- const waiting: EventSimulator;
192
- const wheel: EventSimulator;
193
- }
194
-
195
- /**
196
- * Render a React element into a detached DOM node in the document. __This function requires a DOM__.
197
- * @deprecated https://react.dev/warnings/react-dom-test-utils
198
- */
199
- export function renderIntoDocument<T extends Element>(
200
- element: DOMElement<any, T>,
201
- ): T;
202
- /** @deprecated https://react.dev/warnings/react-dom-test-utils */
203
- export function renderIntoDocument(
204
- element: FunctionComponentElement<any>,
205
- ): void;
206
- // If we replace `P` with `any` in this overload, then some tests fail because
207
- // calls to `renderIntoDocument` choose the last overload on the
208
- // subtype-relation pass and get an undesirably broad return type. Using `P`
209
- // allows this overload to match on the subtype-relation pass.
210
- /**
211
- * @deprecated https://react.dev/warnings/react-dom-test-utils
212
- */
213
- export function renderIntoDocument<P, T extends Component<P>>(
214
- element: CElement<P, T>,
215
- ): T;
216
- /**
217
- * @deprecated https://react.dev/warnings/react-dom-test-utils
218
- */
219
- export function renderIntoDocument<P>(
220
- element: ReactElement<P>,
221
- ): Component<P> | Element | void;
222
-
223
- /**
224
- * Pass a mocked component module to this method to augment it with useful methods that allow it to
225
- * be used as a dummy React component. Instead of rendering as usual, the component will become
226
- * a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
227
- * @deprecated https://react.dev/warnings/react-dom-test-utils
228
- */
229
- export function mockComponent(
230
- mocked: MockedComponentClass,
231
- mockTagName?: string,
232
- ): typeof ReactTestUtils;
233
-
234
- /**
235
- * Returns `true` if `element` is any React element.
236
- * @deprecated https://react.dev/warnings/react-dom-test-utils
237
- */
238
- export function isElement(element: any): boolean;
239
-
240
- /**
241
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
242
- * @deprecated https://react.dev/warnings/react-dom-test-utils
243
- */
244
- export function isElementOfType<T extends HTMLElement>(
245
- element: ReactElement,
246
- type: string,
247
- ): element is ReactHTMLElement<T>;
248
- /**
249
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
250
- * @deprecated https://react.dev/warnings/react-dom-test-utils
251
- */
252
- export function isElementOfType<P extends DOMAttributes<{}>, T extends Element>(
253
- element: ReactElement,
254
- type: string,
255
- ): element is DOMElement<P, T>;
256
- /**
257
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
258
- * @deprecated https://react.dev/warnings/react-dom-test-utils
259
- */
260
- export function isElementOfType<P>(
261
- element: ReactElement,
262
- type: FC<P>,
263
- ): element is FunctionComponentElement<P>;
264
- /**
265
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
266
- * @deprecated https://react.dev/warnings/react-dom-test-utils
267
- */
268
- export function isElementOfType<P, T extends Component<P>, C extends ComponentClass<P>>(
269
- element: ReactElement,
270
- type: ClassType<P, T, C>,
271
- ): element is CElement<P, T>;
272
-
273
- /**
274
- * Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
275
- * @deprecated https://react.dev/warnings/react-dom-test-utils
276
- */
277
- export function isDOMComponent(instance: ReactInstance): instance is Element;
278
- /**
279
- * Returns `true` if `instance` is a user-defined component, such as a class or a function.
280
- * @deprecated https://react.dev/warnings/react-dom-test-utils
281
- */
282
- export function isCompositeComponent(instance: ReactInstance): instance is Component<any>;
283
- /**
284
- * Returns `true` if `instance` is a component whose type is of a React `componentClass`.
285
- * @deprecated https://react.dev/warnings/react-dom-test-utils
286
- */
287
- export function isCompositeComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
288
- instance: ReactInstance,
289
- type: ClassType<any, T, C>,
290
- ): boolean;
291
-
292
- /**
293
- * Traverse all components in `tree` and accumulate all components where
294
- * `test(component)` is `true`. This is not that useful on its own, but it's used
295
- * as a primitive for other test utils.
296
- * @deprecated https://react.dev/warnings/react-dom-test-utils
297
- */
298
- export function findAllInRenderedTree(
299
- root: Component<any>,
300
- fn: (i: ReactInstance) => boolean,
301
- ): ReactInstance[];
302
-
303
- /**
304
- * Finds all DOM elements of components in the rendered tree that are
305
- * DOM components with the class name matching `className`.
306
- * @deprecated https://react.dev/warnings/react-dom-test-utils
307
- */
308
- export function scryRenderedDOMComponentsWithClass(
309
- root: Component<any>,
310
- className: string,
311
- ): Element[];
312
- /**
313
- * Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
314
- * and returns that one result, or throws exception if there is any other
315
- * number of matches besides one.
316
- * @deprecated https://react.dev/warnings/react-dom-test-utils
317
- */
318
- export function findRenderedDOMComponentWithClass(
319
- root: Component<any>,
320
- className: string,
321
- ): Element;
322
-
323
- /**
324
- * Finds all DOM elements of components in the rendered tree that are
325
- * DOM components with the tag name matching `tagName`.
326
- * @deprecated https://react.dev/warnings/react-dom-test-utils
327
- */
328
- export function scryRenderedDOMComponentsWithTag(
329
- root: Component<any>,
330
- tagName: string,
331
- ): Element[];
332
- /**
333
- * Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result,
334
- * and returns that one result, or throws exception if there is any other
335
- * number of matches besides one.
336
- * @deprecated https://react.dev/warnings/react-dom-test-utils
337
- */
338
- export function findRenderedDOMComponentWithTag(
339
- root: Component<any>,
340
- tagName: string,
341
- ): Element;
342
-
343
- /**
344
- * Finds all instances of components with type equal to `componentClass`.
345
- * @deprecated https://react.dev/warnings/react-dom-test-utils
346
- */
347
- export function scryRenderedComponentsWithType<T extends Component<any>, C extends ComponentClass<any>>(
348
- root: Component<any>,
349
- type: ClassType<any, T, C>,
350
- ): T[];
351
-
352
- /**
353
- * Same as `scryRenderedComponentsWithType()` but expects there to be one result
354
- * and returns that one result, or throws exception if there is any other
355
- * number of matches besides one.
356
- * @deprecated https://react.dev/warnings/react-dom-test-utils
357
- */
358
- export function findRenderedComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
359
- root: Component<any>,
360
- type: ClassType<any, T, C>,
361
- ): T;
362
-
363
- /**
364
- * Call this in your tests to create a shallow renderer.
365
- * @deprecated https://react.dev/warnings/react-dom-test-utils
366
- */
367
- export function createRenderer(): ShallowRenderer;
368
-
369
- // NOTES
370
- // - the order of these signatures matters - typescript will check the signatures in source order.
371
- // If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
372
- // `strictNullChecks: false`.
373
- // - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
374
- declare const UNDEFINED_VOID_ONLY: unique symbol;
375
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
376
- type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
377
- /**
378
- * Wrap any code rendering and triggering updates to your components into `act()` calls.
379
- *
380
- * Ensures that the behavior in your tests matches what happens in the browser
381
- * more closely by executing pending `useEffect`s before returning. This also
382
- * reduces the amount of re-renders done.
383
- *
384
- * @param callback A synchronous, void callback that will execute as a single, complete React commit.
385
- *
386
- * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
387
- *
388
- * @deprecated https://react.dev/warnings/react-dom-test-utils
389
- */
390
- // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
391
- export function act(callback: () => VoidOrUndefinedOnly): void;
392
- /**
393
- * @deprecated https://react.dev/warnings/react-dom-test-utils
394
- */
395
- export function act<T>(callback: () => T | Promise<T>): Promise<T>;
396
-
397
- // Intentionally doesn't extend PromiseLike<never>.
398
- // Ideally this should be as hard to accidentally use as possible.
399
- export interface DebugPromiseLike {
400
- // the actual then() in here is 0-ary, but that doesn't count as a PromiseLike.
401
- then(onfulfilled: (value: never) => never, onrejected: (reason: never) => never): never;
402
- }
5
+ * @deprecated Import `act` from `react` instead.
6
+ */ act,
7
+ } from "react";