@types/react-dom 18.3.1 → 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/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for react-dom (https://reactjs.org).
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: Fri, 11 Oct 2024 14:37:45 GMT
11
+ * Last updated: Thu, 05 Dec 2024 19:32:25 GMT
12
12
  * Dependencies: [@types/react](https://npmjs.com/package/@types/react)
13
13
 
14
14
  # Credits
react-dom/canary.d.ts CHANGED
@@ -30,155 +30,3 @@ import React = require("react");
30
30
  import ReactDOM = require(".");
31
31
 
32
32
  export {};
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
- }
184
- }
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
  ];
react-dom/index.d.ts CHANGED
@@ -4,28 +4,7 @@
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
- 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;
7
+ import { Key, ReactNode, ReactPortal } from "react";
29
8
 
30
9
  export function createPortal(
31
10
  children: ReactNode,
@@ -34,117 +13,115 @@ export function createPortal(
34
13
  ): ReactPortal;
35
14
 
36
15
  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
16
 
46
17
  export function flushSync<R>(fn: () => R): R;
47
18
 
48
19
  export function unstable_batchedUpdates<A, R>(callback: (a: A) => R, a: A): R;
49
20
  export function unstable_batchedUpdates<R>(callback: () => R): R;
50
21
 
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;
22
+ export interface FormStatusNotPending {
23
+ pending: false;
24
+ data: null;
25
+ method: null;
26
+ action: null;
27
+ }
112
28
 
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;
29
+ export interface FormStatusPending {
30
+ pending: true;
31
+ data: FormData;
32
+ method: string;
33
+ action: string | ((formData: FormData) => void | Promise<void>);
34
+ }
121
35
 
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>;
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;
130
89
 
90
+ // https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
91
+ export type PreloadModuleAs = RequestDestination;
92
+ export interface PreloadModuleOptions {
131
93
  /**
132
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
94
+ * @default "script"
133
95
  */
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;
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;
140
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 {
141
117
  /**
142
- * @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
118
+ * @default "script"
143
119
  */
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;
120
+ as?: PreinitModuleAs;
121
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
122
+ integrity?: string | undefined;
123
+ nonce?: string | undefined;
150
124
  }
125
+ export function preinitModule(href: string, options?: PreinitModuleOptions): void;
126
+
127
+ 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.1",
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",
@@ -82,6 +82,7 @@
82
82
  "dependencies": {
83
83
  "@types/react": "*"
84
84
  },
85
- "typesPublisherContentHash": "a3dae397f083f79a977be3366dd86cfbcb7da67ad0089da69419978000ba6764",
86
- "typeScriptVersion": "4.8"
85
+ "peerDependencies": {},
86
+ "typesPublisherContentHash": "bfa192efe4d902904df093f5cf45f5bfb86784036b0a929810713bb9fbd1c78c",
87
+ "typeScriptVersion": "5.0"
87
88
  }
react-dom/server.d.ts CHANGED
@@ -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;
@@ -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";