@types/react-dom 18.3.2 → 19.0.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 v18.3/README.md → react-dom/README.md +1 -1
- react-dom/canary.d.ts +32 -0
- react-dom v18.3/client.d.ts → react-dom/client.d.ts +34 -1
- react-dom/experimental.d.ts +36 -0
- react-dom/index.d.ts +127 -0
- react-dom v18.3/package.json → react-dom/package.json +13 -3
- react-dom v18.3/server.d.ts → react-dom/server.d.ts +0 -18
- react-dom/test-utils/index.d.ts +7 -0
- react-dom v18.3/index.d.ts +0 -150
- react-dom v18.3/test-utils/index.d.ts +0 -402
- {react-dom v18.3 → react-dom}/LICENSE +0 -0
@@ -5,7 +5,7 @@
|
|
5
5
|
This package contains type definitions for react-dom (https://reactjs.org).
|
6
6
|
|
7
7
|
# Details
|
8
|
-
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom
|
8
|
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom.
|
9
9
|
|
10
10
|
### Additional Details
|
11
11
|
* Last updated: Thu, 05 Dec 2024 19:32:25 GMT
|
react-dom/canary.d.ts
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* These are types for things that are present in the upcoming React 18 release.
|
3
|
+
*
|
4
|
+
* Once React 18 is released they can just be moved to the main index file.
|
5
|
+
*
|
6
|
+
* To load the types declared here in an actual project, there are three ways. The easiest one,
|
7
|
+
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
|
8
|
+
* is to add `"react-dom/canary"` to the `"types"` array.
|
9
|
+
*
|
10
|
+
* Alternatively, a specific import syntax can to be used from a typescript file.
|
11
|
+
* This module does not exist in reality, which is why the {} is important:
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* import {} from 'react-dom/canary'
|
15
|
+
* ```
|
16
|
+
*
|
17
|
+
* It is also possible to include it through a triple-slash reference:
|
18
|
+
*
|
19
|
+
* ```ts
|
20
|
+
* /// <reference types="react-dom/canary" />
|
21
|
+
* ```
|
22
|
+
*
|
23
|
+
* Either the import or the reference only needs to appear once, anywhere in the project.
|
24
|
+
*/
|
25
|
+
|
26
|
+
// See https://github.com/facebook/react/blob/main/packages/react-dom/index.js to see how the exports are declared,
|
27
|
+
// but confirm with published source code (e.g. https://unpkg.com/react-dom@canary) that these exports end up in the published code
|
28
|
+
|
29
|
+
import React = require("react");
|
30
|
+
import ReactDOM = require(".");
|
31
|
+
|
32
|
+
export {};
|
@@ -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
|
];
|
@@ -0,0 +1,36 @@
|
|
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-dom/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-dom/experimental'
|
16
|
+
* ```
|
17
|
+
*
|
18
|
+
* It is also possible to include it through a triple-slash reference:
|
19
|
+
*
|
20
|
+
* ```ts
|
21
|
+
* /// <reference types="react-dom/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/main/packages/react-dom/index.experimental.js to see how the exports are declared,
|
28
|
+
// but confirm with published source code (e.g. https://unpkg.com/react-dom@experimental) that these exports end up in the published code
|
29
|
+
|
30
|
+
import React = require("react");
|
31
|
+
import ReactDOM = require("./canary");
|
32
|
+
|
33
|
+
export {};
|
34
|
+
|
35
|
+
declare module "." {
|
36
|
+
}
|
react-dom/index.d.ts
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
// NOTE: Users of the `experimental` builds of React should add a reference
|
2
|
+
// to 'react-dom/experimental' in their project. See experimental.d.ts's top comment
|
3
|
+
// for reference and documentation on how exactly to do it.
|
4
|
+
|
5
|
+
export as namespace ReactDOM;
|
6
|
+
|
7
|
+
import { Key, ReactNode, ReactPortal } from "react";
|
8
|
+
|
9
|
+
export function createPortal(
|
10
|
+
children: ReactNode,
|
11
|
+
container: Element | DocumentFragment,
|
12
|
+
key?: Key | null,
|
13
|
+
): ReactPortal;
|
14
|
+
|
15
|
+
export const version: string;
|
16
|
+
|
17
|
+
export function flushSync<R>(fn: () => R): R;
|
18
|
+
|
19
|
+
export function unstable_batchedUpdates<A, R>(callback: (a: A) => R, a: A): R;
|
20
|
+
export function unstable_batchedUpdates<R>(callback: () => R): R;
|
21
|
+
|
22
|
+
export interface FormStatusNotPending {
|
23
|
+
pending: false;
|
24
|
+
data: null;
|
25
|
+
method: null;
|
26
|
+
action: null;
|
27
|
+
}
|
28
|
+
|
29
|
+
export interface FormStatusPending {
|
30
|
+
pending: true;
|
31
|
+
data: FormData;
|
32
|
+
method: string;
|
33
|
+
action: string | ((formData: FormData) => void | Promise<void>);
|
34
|
+
}
|
35
|
+
|
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
|
+
}
|
88
|
+
export function preload(href: string, options?: PreloadOptions): void;
|
89
|
+
|
90
|
+
// https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
|
91
|
+
export type PreloadModuleAs = RequestDestination;
|
92
|
+
export interface PreloadModuleOptions {
|
93
|
+
/**
|
94
|
+
* @default "script"
|
95
|
+
*/
|
96
|
+
as: PreloadModuleAs;
|
97
|
+
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
|
98
|
+
integrity?: string | undefined;
|
99
|
+
nonce?: string | undefined;
|
100
|
+
}
|
101
|
+
export function preloadModule(href: string, options?: PreloadModuleOptions): void;
|
102
|
+
|
103
|
+
export type PreinitAs = "script" | "style";
|
104
|
+
export interface PreinitOptions {
|
105
|
+
as: PreinitAs;
|
106
|
+
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
|
107
|
+
fetchPriority?: "high" | "low" | "auto" | undefined;
|
108
|
+
precedence?: string | undefined;
|
109
|
+
integrity?: string | undefined;
|
110
|
+
nonce?: string | undefined;
|
111
|
+
}
|
112
|
+
export function preinit(href: string, options?: PreinitOptions): void;
|
113
|
+
|
114
|
+
// Will be expanded to include all of https://github.com/tc39/proposal-import-attributes
|
115
|
+
export type PreinitModuleAs = "script";
|
116
|
+
export interface PreinitModuleOptions {
|
117
|
+
/**
|
118
|
+
* @default "script"
|
119
|
+
*/
|
120
|
+
as?: PreinitModuleAs;
|
121
|
+
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
|
122
|
+
integrity?: string | undefined;
|
123
|
+
nonce?: string | undefined;
|
124
|
+
}
|
125
|
+
export function preinitModule(href: string, options?: PreinitModuleOptions): void;
|
126
|
+
|
127
|
+
export function requestFormReset(form: HTMLFormElement): void;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react-dom",
|
3
|
-
"version": "
|
3
|
+
"version": "19.0.0",
|
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",
|
@@ -51,11 +51,21 @@
|
|
51
51
|
"default": "./client.d.ts"
|
52
52
|
}
|
53
53
|
},
|
54
|
+
"./canary": {
|
55
|
+
"types": {
|
56
|
+
"default": "./canary.d.ts"
|
57
|
+
}
|
58
|
+
},
|
54
59
|
"./server": {
|
55
60
|
"types": {
|
56
61
|
"default": "./server.d.ts"
|
57
62
|
}
|
58
63
|
},
|
64
|
+
"./experimental": {
|
65
|
+
"types": {
|
66
|
+
"default": "./experimental.d.ts"
|
67
|
+
}
|
68
|
+
},
|
59
69
|
"./test-utils": {
|
60
70
|
"types": {
|
61
71
|
"default": "./test-utils/index.d.ts"
|
@@ -70,9 +80,9 @@
|
|
70
80
|
},
|
71
81
|
"scripts": {},
|
72
82
|
"dependencies": {
|
73
|
-
"@types/react": "
|
83
|
+
"@types/react": "*"
|
74
84
|
},
|
75
85
|
"peerDependencies": {},
|
76
|
-
"typesPublisherContentHash": "
|
86
|
+
"typesPublisherContentHash": "bfa192efe4d902904df093f5cf45f5bfb86784036b0a929810713bb9fbd1c78c",
|
77
87
|
"typeScriptVersion": "5.0"
|
78
88
|
}
|
@@ -69,15 +69,6 @@ export function renderToPipeableStream(children: ReactNode, options?: RenderToPi
|
|
69
69
|
*/
|
70
70
|
export function renderToString(element: ReactNode, options?: ServerOptions): string;
|
71
71
|
|
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
72
|
/**
|
82
73
|
* Similar to `renderToString`, except this doesn't create extra DOM attributes
|
83
74
|
* such as `data-reactid`, that React uses internally. This is useful if you want
|
@@ -86,15 +77,6 @@ export function renderToNodeStream(element: ReactNode, options?: ServerOptions):
|
|
86
77
|
*/
|
87
78
|
export function renderToStaticMarkup(element: ReactNode, options?: ServerOptions): string;
|
88
79
|
|
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
80
|
export interface RenderToReadableStreamOptions {
|
99
81
|
identifierPrefix?: string;
|
100
82
|
namespaceURI?: string;
|
react-dom v18.3/index.d.ts
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
// NOTE: Users of the `experimental` builds of React should add a reference
|
2
|
-
// to 'react-dom/experimental' in their project. See experimental.d.ts's top comment
|
3
|
-
// for reference and documentation on how exactly to do it.
|
4
|
-
|
5
|
-
export as namespace ReactDOM;
|
6
|
-
|
7
|
-
import {
|
8
|
-
CElement,
|
9
|
-
Component,
|
10
|
-
ComponentState,
|
11
|
-
DOMAttributes,
|
12
|
-
DOMElement,
|
13
|
-
FunctionComponentElement,
|
14
|
-
Key,
|
15
|
-
ReactElement,
|
16
|
-
ReactInstance,
|
17
|
-
ReactNode,
|
18
|
-
ReactPortal,
|
19
|
-
} from "react";
|
20
|
-
|
21
|
-
/**
|
22
|
-
* @deprecated See https://react.dev/reference/react-dom/findDOMNode#alternatives
|
23
|
-
*/
|
24
|
-
export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
|
25
|
-
/**
|
26
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
27
|
-
*/
|
28
|
-
export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
|
29
|
-
|
30
|
-
export function createPortal(
|
31
|
-
children: ReactNode,
|
32
|
-
container: Element | DocumentFragment,
|
33
|
-
key?: Key | null,
|
34
|
-
): ReactPortal;
|
35
|
-
|
36
|
-
export const version: string;
|
37
|
-
/**
|
38
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
39
|
-
*/
|
40
|
-
export const render: Renderer;
|
41
|
-
/**
|
42
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
43
|
-
*/
|
44
|
-
export const hydrate: Renderer;
|
45
|
-
|
46
|
-
export function flushSync<R>(fn: () => R): R;
|
47
|
-
|
48
|
-
export function unstable_batchedUpdates<A, R>(callback: (a: A) => R, a: A): R;
|
49
|
-
export function unstable_batchedUpdates<R>(callback: () => R): R;
|
50
|
-
|
51
|
-
/**
|
52
|
-
* @deprecated
|
53
|
-
*/
|
54
|
-
export function unstable_renderSubtreeIntoContainer<T extends Element>(
|
55
|
-
parentComponent: Component<any>,
|
56
|
-
element: DOMElement<DOMAttributes<T>, T>,
|
57
|
-
container: Element,
|
58
|
-
callback?: (element: T) => any,
|
59
|
-
): T;
|
60
|
-
/**
|
61
|
-
* @deprecated
|
62
|
-
*/
|
63
|
-
export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
|
64
|
-
parentComponent: Component<any>,
|
65
|
-
element: CElement<P, T>,
|
66
|
-
container: Element,
|
67
|
-
callback?: (component: T) => any,
|
68
|
-
): T;
|
69
|
-
/**
|
70
|
-
* @deprecated
|
71
|
-
*/
|
72
|
-
export function unstable_renderSubtreeIntoContainer<P>(
|
73
|
-
parentComponent: Component<any>,
|
74
|
-
element: ReactElement<P>,
|
75
|
-
container: Element,
|
76
|
-
callback?: (component?: Component<P, ComponentState> | Element) => any,
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
78
|
-
): Component<P, ComponentState> | Element | void;
|
79
|
-
|
80
|
-
export type Container = Element | Document | DocumentFragment;
|
81
|
-
|
82
|
-
export interface Renderer {
|
83
|
-
// Deprecated(render): The return value is deprecated.
|
84
|
-
// In future releases the render function's return type will be void.
|
85
|
-
|
86
|
-
/**
|
87
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
88
|
-
*/
|
89
|
-
<T extends Element>(
|
90
|
-
element: DOMElement<DOMAttributes<T>, T>,
|
91
|
-
container: Container | null,
|
92
|
-
callback?: () => void,
|
93
|
-
): T;
|
94
|
-
|
95
|
-
/**
|
96
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
97
|
-
*/
|
98
|
-
(
|
99
|
-
element: Array<DOMElement<DOMAttributes<any>, any>>,
|
100
|
-
container: Container | null,
|
101
|
-
callback?: () => void,
|
102
|
-
): Element;
|
103
|
-
|
104
|
-
/**
|
105
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
106
|
-
*/
|
107
|
-
(
|
108
|
-
element: FunctionComponentElement<any> | Array<FunctionComponentElement<any>>,
|
109
|
-
container: Container | null,
|
110
|
-
callback?: () => void,
|
111
|
-
): void;
|
112
|
-
|
113
|
-
/**
|
114
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
115
|
-
*/
|
116
|
-
<P, T extends Component<P, ComponentState>>(
|
117
|
-
element: CElement<P, T>,
|
118
|
-
container: Container | null,
|
119
|
-
callback?: () => void,
|
120
|
-
): T;
|
121
|
-
|
122
|
-
/**
|
123
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
124
|
-
*/
|
125
|
-
(
|
126
|
-
element: Array<CElement<any, Component<any, ComponentState>>>,
|
127
|
-
container: Container | null,
|
128
|
-
callback?: () => void,
|
129
|
-
): Component<any, ComponentState>;
|
130
|
-
|
131
|
-
/**
|
132
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
133
|
-
*/
|
134
|
-
<P>(
|
135
|
-
element: ReactElement<P>,
|
136
|
-
container: Container | null,
|
137
|
-
callback?: () => void,
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
139
|
-
): Component<P, ComponentState> | Element | void;
|
140
|
-
|
141
|
-
/**
|
142
|
-
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
|
143
|
-
*/
|
144
|
-
(
|
145
|
-
element: ReactElement[],
|
146
|
-
container: Container | null,
|
147
|
-
callback?: () => void,
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
149
|
-
): Component<any, ComponentState> | Element | void;
|
150
|
-
}
|
@@ -1,402 +0,0 @@
|
|
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
|
-
export {};
|
19
|
-
|
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;
|
96
|
-
/**
|
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
|
-
}
|
File without changes
|