@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/test-utils/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
|
|
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";
|