@types/react-dom 18.3.0 → 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-dom/README.md +4 -3
- react-dom/canary.d.ts +2 -152
- react-dom/client.d.ts +34 -1
- react-dom/experimental.d.ts +51 -0
- react-dom/index.d.ts +105 -121
- react-dom/package.json +46 -5
- react-dom/server.browser.d.ts +1 -0
- react-dom/server.bun.d.ts +1 -0
- react-dom/server.d.ts +80 -23
- react-dom/server.edge.d.ts +1 -0
- react-dom/server.node.d.ts +8 -0
- react-dom/static.browser.d.ts +1 -0
- react-dom/static.d.ts +153 -0
- react-dom/static.edge.d.ts +1 -0
- react-dom/static.node.d.ts +7 -0
- react-dom/test-utils/index.d.ts +4 -399
react-dom/server.d.ts
CHANGED
|
@@ -22,20 +22,64 @@ declare global {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
import { ReactNode } from "react";
|
|
25
|
-
import { ErrorInfo } from "./client";
|
|
25
|
+
import { ErrorInfo, ReactFormState } from "./client";
|
|
26
|
+
import { PostponedState, ResumeOptions } from "./static";
|
|
27
|
+
|
|
28
|
+
export interface BootstrapScriptDescriptor {
|
|
29
|
+
src: string;
|
|
30
|
+
integrity?: string | undefined;
|
|
31
|
+
crossOrigin?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap Import maps}
|
|
36
|
+
*/
|
|
37
|
+
// TODO: Ideally TypeScripts standard library would include this type.
|
|
38
|
+
// Until then we keep the prefixed one for future compatibility.
|
|
39
|
+
export interface ReactImportMap {
|
|
40
|
+
/**
|
|
41
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#imports `imports` reference}
|
|
42
|
+
*/
|
|
43
|
+
imports?: {
|
|
44
|
+
[specifier: string]: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#integrity `integrity` reference}
|
|
48
|
+
*/
|
|
49
|
+
integrity?: {
|
|
50
|
+
[moduleURL: string]: string;
|
|
51
|
+
} | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#scopes `scopes` reference}
|
|
54
|
+
*/
|
|
55
|
+
scopes?: {
|
|
56
|
+
[scope: string]: {
|
|
57
|
+
[specifier: string]: string;
|
|
58
|
+
};
|
|
59
|
+
} | undefined;
|
|
60
|
+
}
|
|
26
61
|
|
|
27
62
|
export interface RenderToPipeableStreamOptions {
|
|
28
63
|
identifierPrefix?: string;
|
|
29
64
|
namespaceURI?: string;
|
|
30
65
|
nonce?: string;
|
|
31
66
|
bootstrapScriptContent?: string;
|
|
32
|
-
bootstrapScripts?: string
|
|
33
|
-
bootstrapModules?: string
|
|
67
|
+
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
68
|
+
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
69
|
+
/**
|
|
70
|
+
* Maximum length of the header content in unicode code units i.e. string.length.
|
|
71
|
+
* Must be a positive integer if specified.
|
|
72
|
+
* @default 2000
|
|
73
|
+
*/
|
|
74
|
+
headersLengthHint?: number | undefined;
|
|
75
|
+
importMap?: ReactImportMap | undefined;
|
|
34
76
|
progressiveChunkSize?: number;
|
|
77
|
+
onHeaders?: ((headers: Headers) => void) | undefined;
|
|
35
78
|
onShellReady?: () => void;
|
|
36
79
|
onShellError?: (error: unknown) => void;
|
|
37
80
|
onAllReady?: () => void;
|
|
38
81
|
onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
|
|
82
|
+
formState?: ReactFormState | null;
|
|
39
83
|
}
|
|
40
84
|
|
|
41
85
|
export interface PipeableStream {
|
|
@@ -69,15 +113,6 @@ export function renderToPipeableStream(children: ReactNode, options?: RenderToPi
|
|
|
69
113
|
*/
|
|
70
114
|
export function renderToString(element: ReactNode, options?: ServerOptions): string;
|
|
71
115
|
|
|
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
116
|
/**
|
|
82
117
|
* Similar to `renderToString`, except this doesn't create extra DOM attributes
|
|
83
118
|
* such as `data-reactid`, that React uses internally. This is useful if you want
|
|
@@ -86,25 +121,25 @@ export function renderToNodeStream(element: ReactNode, options?: ServerOptions):
|
|
|
86
121
|
*/
|
|
87
122
|
export function renderToStaticMarkup(element: ReactNode, options?: ServerOptions): string;
|
|
88
123
|
|
|
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
124
|
export interface RenderToReadableStreamOptions {
|
|
99
125
|
identifierPrefix?: string;
|
|
126
|
+
importMap?: ReactImportMap | undefined;
|
|
100
127
|
namespaceURI?: string;
|
|
101
128
|
nonce?: string;
|
|
102
129
|
bootstrapScriptContent?: string;
|
|
103
|
-
bootstrapScripts?: string
|
|
104
|
-
bootstrapModules?: string
|
|
130
|
+
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
131
|
+
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
132
|
+
/**
|
|
133
|
+
* Maximum length of the header content in unicode code units i.e. string.length.
|
|
134
|
+
* Must be a positive integer if specified.
|
|
135
|
+
* @default 2000
|
|
136
|
+
*/
|
|
137
|
+
headersLengthHint?: number | undefined;
|
|
105
138
|
progressiveChunkSize?: number;
|
|
106
139
|
signal?: AbortSignal;
|
|
107
140
|
onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
|
|
141
|
+
onHeaders?: ((headers: Headers) => void) | undefined;
|
|
142
|
+
formState?: ReactFormState | null;
|
|
108
143
|
}
|
|
109
144
|
|
|
110
145
|
export interface ReactDOMServerReadableStream extends ReadableStream {
|
|
@@ -121,6 +156,28 @@ export function renderToReadableStream(
|
|
|
121
156
|
options?: RenderToReadableStreamOptions,
|
|
122
157
|
): Promise<ReactDOMServerReadableStream>;
|
|
123
158
|
|
|
159
|
+
export { ResumeOptions };
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @see {@link https://react.dev/reference/react-dom/server/resume `resume`` reference documentation}
|
|
163
|
+
* @version 19.2
|
|
164
|
+
*/
|
|
165
|
+
export function resume(
|
|
166
|
+
children: React.ReactNode,
|
|
167
|
+
postponedState: PostponedState,
|
|
168
|
+
options?: ResumeOptions,
|
|
169
|
+
): Promise<ReactDOMServerReadableStream>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @see {@link https://react.dev/reference/react-dom/server/resumeToPipeableStream `resumeToPipeableStream`` reference documentation}
|
|
173
|
+
* @version 19.2
|
|
174
|
+
*/
|
|
175
|
+
export function resumeToPipeableStream(
|
|
176
|
+
children: React.ReactNode,
|
|
177
|
+
postponedState: PostponedState,
|
|
178
|
+
options?: ResumeOptions,
|
|
179
|
+
): Promise<PipeableStream>;
|
|
180
|
+
|
|
124
181
|
export const version: string;
|
|
125
182
|
|
|
126
183
|
export as namespace ReactDOMServer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderToReadableStream, renderToStaticMarkup, renderToString, resume } from "./server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { prerender, version } from "./static";
|
react-dom/static.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
export {};
|
|
30
|
+
|
|
31
|
+
declare const POSTPONED_STATE_SIGIL: unique symbol;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This is an opaque type i.e. users should not make any assumptions about its structure.
|
|
35
|
+
* It is JSON-serializeable to be a able to store it and retrvieve later for use with {@link https://react.dev/reference/react-dom/server/resume `resume`}.
|
|
36
|
+
*/
|
|
37
|
+
export interface PostponedState {
|
|
38
|
+
[POSTPONED_STATE_SIGIL]: never;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap Import maps}
|
|
43
|
+
*/
|
|
44
|
+
// TODO: Ideally TypeScripts standard library would include this type.
|
|
45
|
+
// Until then we keep the prefixed one for future compatibility.
|
|
46
|
+
export interface ReactImportMap {
|
|
47
|
+
/**
|
|
48
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#imports `imports` reference}
|
|
49
|
+
*/
|
|
50
|
+
imports?: {
|
|
51
|
+
[specifier: string]: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#integrity `integrity` reference}
|
|
55
|
+
*/
|
|
56
|
+
integrity?: {
|
|
57
|
+
[moduleURL: string]: string;
|
|
58
|
+
} | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#scopes `scopes` reference}
|
|
61
|
+
*/
|
|
62
|
+
scopes?: {
|
|
63
|
+
[scope: string]: {
|
|
64
|
+
[specifier: string]: string;
|
|
65
|
+
};
|
|
66
|
+
} | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface BootstrapScriptDescriptor {
|
|
70
|
+
src: string;
|
|
71
|
+
integrity?: string | undefined;
|
|
72
|
+
crossOrigin?: string | undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface PrerenderOptions {
|
|
76
|
+
bootstrapScriptContent?: string;
|
|
77
|
+
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
|
|
78
|
+
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
|
|
79
|
+
/**
|
|
80
|
+
* Maximum length of the header content in unicode code units i.e. string.length.
|
|
81
|
+
* Must be a positive integer if specified.
|
|
82
|
+
* @default 2000
|
|
83
|
+
*/
|
|
84
|
+
headersLengthHint?: number | undefined;
|
|
85
|
+
identifierPrefix?: string;
|
|
86
|
+
importMap?: ReactImportMap | undefined;
|
|
87
|
+
namespaceURI?: string;
|
|
88
|
+
onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
|
|
89
|
+
onHeaders?: (headers: Headers) => void | undefined;
|
|
90
|
+
progressiveChunkSize?: number;
|
|
91
|
+
signal?: AbortSignal;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface PrerenderResult {
|
|
95
|
+
postponed: null | PostponedState;
|
|
96
|
+
prelude: ReadableStream<Uint8Array>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 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).
|
|
101
|
+
*
|
|
102
|
+
* @see [API](https://react.dev/reference/react-dom/static/prerender)
|
|
103
|
+
*/
|
|
104
|
+
export function prerender(
|
|
105
|
+
reactNode: ReactNode,
|
|
106
|
+
options?: PrerenderOptions,
|
|
107
|
+
): Promise<PrerenderResult>;
|
|
108
|
+
|
|
109
|
+
export interface PrerenderToNodeStreamResult {
|
|
110
|
+
prelude: NodeJS.ReadableStream;
|
|
111
|
+
postponed: null | PostponedState;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Only available in the environments with [Node.js Streams](https://nodejs.dev/learn/nodejs-streams).
|
|
116
|
+
*
|
|
117
|
+
* @see [API](https://react.dev/reference/react-dom/static/prerenderToNodeStream)
|
|
118
|
+
*
|
|
119
|
+
* @param children
|
|
120
|
+
* @param options
|
|
121
|
+
*/
|
|
122
|
+
export function prerenderToNodeStream(
|
|
123
|
+
reactNode: ReactNode,
|
|
124
|
+
options?: PrerenderOptions,
|
|
125
|
+
): Promise<PrerenderToNodeStreamResult>;
|
|
126
|
+
|
|
127
|
+
export interface ResumeOptions {
|
|
128
|
+
nonce?: string;
|
|
129
|
+
signal?: AbortSignal;
|
|
130
|
+
onError?: (error: unknown) => string | undefined | void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @see {@link https://react.dev/reference/react-dom/static/resumeAndPrerender `resumeAndPrerender` reference documentation}
|
|
135
|
+
* @version 19.2
|
|
136
|
+
*/
|
|
137
|
+
export function resumeAndPrerender(
|
|
138
|
+
children: React.ReactNode,
|
|
139
|
+
postponedState: null | PostponedState,
|
|
140
|
+
options?: Omit<ResumeOptions, "nonce">,
|
|
141
|
+
): Promise<PrerenderResult>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @see {@link https://react.dev/reference/react-dom/static/resumeAndPrerenderToNodeStream `resumeAndPrerenderToNodeStream`` reference documentation}
|
|
145
|
+
* @version 19.2
|
|
146
|
+
*/
|
|
147
|
+
export function resumeAndPrerenderToNodeStream(
|
|
148
|
+
children: React.ReactNode,
|
|
149
|
+
postponedState: null | PostponedState,
|
|
150
|
+
options?: Omit<ResumeOptions, "nonce">,
|
|
151
|
+
): Promise<PrerenderToNodeStreamResult>;
|
|
152
|
+
|
|
153
|
+
export const version: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { prerender, resumeAndPrerender, version } from "./static";
|