@types/react-dom 16.0.8 → 16.8.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
@@ -2,15 +2,15 @@
2
2
  > `npm install --save @types/react-dom`
3
3
 
4
4
  # Summary
5
- This package contains type definitions for React (react-dom) (http://facebook.github.io/react/).
5
+ This package contains type definitions for React (react-dom) ( http://facebook.github.io/react/ ).
6
6
 
7
7
  # Details
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom
9
9
 
10
10
  Additional Details
11
- * Last updated: Thu, 27 Sep 2018 12:34:24 GMT
12
- * Dependencies: react, node
11
+ * Last updated: Wed, 06 Feb 2019 12:44:09 GMT
12
+ * Dependencies: @types/react
13
13
  * Global values: ReactDOM, ReactDOMNodeStream, ReactDOMServer
14
14
 
15
15
  # Credits
16
- These definitions were written by Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>, MartynasZilinskas <https://github.com/MartynasZilinskas>, Josh Rutherford <https://github.com/theruther4d>, JounQin <https://github.com/JounQin>.
16
+ These definitions were written by Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>, MartynasZilinskas <https://github.com/MartynasZilinskas>, Josh Rutherford <https://github.com/theruther4d>, Jessica Franco <https://github.com/Jessidhia>.
react-dom/index.d.ts CHANGED
@@ -1,101 +1,101 @@
1
- // Type definitions for React (react-dom) 16.0
2
- // Project: http://facebook.github.io/react/
3
- // Definitions by: Asana <https://asana.com>
4
- // AssureSign <http://www.assuresign.com>
5
- // Microsoft <https://microsoft.com>
6
- // MartynasZilinskas <https://github.com/MartynasZilinskas>
7
- // Josh Rutherford <https://github.com/theruther4d>
8
- // JounQin <https://github.com/JounQin>
9
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10
- // TypeScript Version: 2.8
11
-
12
- export as namespace ReactDOM;
13
-
14
- import {
15
- ReactInstance, Component, ComponentState,
16
- ReactElement, SFCElement, CElement,
17
- DOMAttributes, DOMElement, ReactNode, ReactPortal
18
- } from 'react';
19
-
20
- export function findDOMNode(instance: ReactInstance): Element | string | null;
21
- export function unmountComponentAtNode(container: Element): boolean;
22
-
23
- export function createPortal(children: ReactNode, container: Element, key?: null | string): ReactPortal;
24
-
25
- export const version: string;
26
- export const render: Renderer;
27
- export const hydrate: Renderer;
28
-
29
- export function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
30
- export function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
31
- export function unstable_batchedUpdates(callback: () => any): void;
32
-
33
- export function unstable_renderSubtreeIntoContainer<T extends Element>(
34
- parentComponent: Component<any>,
35
- element: DOMElement<DOMAttributes<T>, T>,
36
- container: Element,
37
- callback?: (element: T) => any): T;
38
- export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
39
- parentComponent: Component<any>,
40
- element: CElement<P, T>,
41
- container: Element,
42
- callback?: (component: T) => any): T;
43
- export function unstable_renderSubtreeIntoContainer<P>(
44
- parentComponent: Component<any>,
45
- element: ReactElement<P>,
46
- container: Element,
47
- callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
48
-
49
- export interface Renderer {
50
- // Deprecated(render): The return value is deprecated.
51
- // In future releases the render function's return type will be void.
52
-
53
- <T extends Element>(
54
- element: DOMElement<DOMAttributes<T>, T>,
55
- container: Element | null,
56
- callback?: () => void
57
- ): T;
58
-
59
- (
60
- element: Array<DOMElement<DOMAttributes<any>, any>>,
61
- container: Element | null,
62
- callback?: () => void
63
- ): Element;
64
-
65
- (
66
- element: SFCElement<any> | Array<SFCElement<any>>,
67
- container: Element | null,
68
- callback?: () => void
69
- ): void;
70
-
71
- <P, T extends Component<P, ComponentState>>(
72
- element: CElement<P, T>,
73
- container: Element | null,
74
- callback?: () => void
75
- ): T;
76
-
77
- (
78
- element: Array<CElement<any, Component<any, ComponentState>>>,
79
- container: Element | null,
80
- callback?: () => void
81
- ): Component<any, ComponentState>;
82
-
83
- <P>(
84
- element: ReactElement<P>,
85
- container: Element | null,
86
- callback?: () => void
87
- ): Component<P, ComponentState> | Element | void;
88
-
89
- (
90
- element: Array<ReactElement<any>>,
91
- container: Element | null,
92
- callback?: () => void
93
- ): Component<any, ComponentState> | Element | void;
94
-
95
- (
96
- parentComponent: Component<any> | Array<Component<any>>,
97
- element: SFCElement<any>,
98
- container: Element,
99
- callback?: () => void
100
- ): void;
101
- }
1
+ // Type definitions for React (react-dom) 16.8
2
+ // Project: http://facebook.github.io/react/
3
+ // Definitions by: Asana <https://asana.com>
4
+ // AssureSign <http://www.assuresign.com>
5
+ // Microsoft <https://microsoft.com>
6
+ // MartynasZilinskas <https://github.com/MartynasZilinskas>
7
+ // Josh Rutherford <https://github.com/theruther4d>
8
+ // Jessica Franco <https://github.com/Jessidhia>
9
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10
+ // TypeScript Version: 2.8
11
+
12
+ export as namespace ReactDOM;
13
+
14
+ import {
15
+ ReactInstance, Component, ComponentState,
16
+ ReactElement, SFCElement, CElement,
17
+ DOMAttributes, DOMElement, ReactNode, ReactPortal
18
+ } from 'react';
19
+
20
+ export function findDOMNode(instance: ReactInstance): Element | null | Text;
21
+ export function unmountComponentAtNode(container: Element): boolean;
22
+
23
+ export function createPortal(children: ReactNode, container: Element, key?: null | string): ReactPortal;
24
+
25
+ export const version: string;
26
+ export const render: Renderer;
27
+ export const hydrate: Renderer;
28
+
29
+ export function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
30
+ export function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
31
+ export function unstable_batchedUpdates(callback: () => any): void;
32
+
33
+ export function unstable_renderSubtreeIntoContainer<T extends Element>(
34
+ parentComponent: Component<any>,
35
+ element: DOMElement<DOMAttributes<T>, T>,
36
+ container: Element,
37
+ callback?: (element: T) => any): T;
38
+ export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
39
+ parentComponent: Component<any>,
40
+ element: CElement<P, T>,
41
+ container: Element,
42
+ callback?: (component: T) => any): T;
43
+ export function unstable_renderSubtreeIntoContainer<P>(
44
+ parentComponent: Component<any>,
45
+ element: ReactElement<P>,
46
+ container: Element,
47
+ callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
48
+
49
+ export interface Renderer {
50
+ // Deprecated(render): The return value is deprecated.
51
+ // In future releases the render function's return type will be void.
52
+
53
+ <T extends Element>(
54
+ element: DOMElement<DOMAttributes<T>, T>,
55
+ container: Element | null,
56
+ callback?: () => void
57
+ ): T;
58
+
59
+ (
60
+ element: Array<DOMElement<DOMAttributes<any>, any>>,
61
+ container: Element | null,
62
+ callback?: () => void
63
+ ): Element;
64
+
65
+ (
66
+ element: SFCElement<any> | Array<SFCElement<any>>,
67
+ container: Element | null,
68
+ callback?: () => void
69
+ ): void;
70
+
71
+ <P, T extends Component<P, ComponentState>>(
72
+ element: CElement<P, T>,
73
+ container: Element | null,
74
+ callback?: () => void
75
+ ): T;
76
+
77
+ (
78
+ element: Array<CElement<any, Component<any, ComponentState>>>,
79
+ container: Element | null,
80
+ callback?: () => void
81
+ ): Component<any, ComponentState>;
82
+
83
+ <P>(
84
+ element: ReactElement<P>,
85
+ container: Element | null,
86
+ callback?: () => void
87
+ ): Component<P, ComponentState> | Element | void;
88
+
89
+ (
90
+ element: Array<ReactElement<any>>,
91
+ container: Element | null,
92
+ callback?: () => void
93
+ ): Component<any, ComponentState> | Element | void;
94
+
95
+ (
96
+ parentComponent: Component<any> | Array<Component<any>>,
97
+ element: SFCElement<any>,
98
+ container: Element,
99
+ callback?: () => void
100
+ ): void;
101
+ }
@@ -1,18 +1,18 @@
1
- import { ReactElement } from 'react';
2
-
3
- /**
4
- * Render a ReactElement to its initial HTML. This should only be used on the
5
- * server.
6
- * See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostream
7
- */
8
- export function renderToStream(element: ReactElement<any>): any;
9
-
10
- /**
11
- * Similar to renderToStream, except this doesn't create extra DOM attributes
12
- * such as data-react-id that React uses internally.
13
- * See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostaticstream
14
- */
15
- export function renderToStaticStream(element: ReactElement<any>): any;
16
- export const version: string;
17
-
18
- export as namespace ReactDOMNodeStream;
1
+ import { ReactElement } from 'react';
2
+
3
+ /**
4
+ * Render a ReactElement to its initial HTML. This should only be used on the
5
+ * server.
6
+ * See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostream
7
+ */
8
+ export function renderToStream(element: ReactElement<any>): any;
9
+
10
+ /**
11
+ * Similar to renderToStream, except this doesn't create extra DOM attributes
12
+ * such as data-react-id that React uses internally.
13
+ * See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostaticstream
14
+ */
15
+ export function renderToStaticStream(element: ReactElement<any>): any;
16
+ export const version: string;
17
+
18
+ export as namespace ReactDOMNodeStream;
react-dom/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react-dom",
3
- "version": "16.0.8",
3
+ "version": "16.8.0",
4
4
  "description": "TypeScript definitions for React (react-dom)",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -27,21 +27,21 @@
27
27
  "githubUsername": "theruther4d"
28
28
  },
29
29
  {
30
- "name": "JounQin",
31
- "url": "https://github.com/JounQin",
32
- "githubUsername": "JounQin"
30
+ "name": "Jessica Franco",
31
+ "url": "https://github.com/Jessidhia",
32
+ "githubUsername": "Jessidhia"
33
33
  }
34
34
  ],
35
35
  "main": "",
36
+ "types": "index",
36
37
  "repository": {
37
38
  "type": "git",
38
39
  "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
39
40
  },
40
41
  "scripts": {},
41
42
  "dependencies": {
42
- "@types/react": "*",
43
- "@types/node": "*"
43
+ "@types/react": "*"
44
44
  },
45
- "typesPublisherContentHash": "3acfd1c0fb518725f930263c862b2bcfa39236c3dd341111477e7cc26ee28bca",
45
+ "typesPublisherContentHash": "b994ac5eaa6eee18cef16c10c5734b4831ad0c2a141f32fa1bbffef28edd6bc0",
46
46
  "typeScriptVersion": "2.8"
47
47
  }
@@ -1,41 +1,47 @@
1
- /// <reference types="node" />
2
-
3
- import { ReactElement } from 'react';
4
-
5
- /**
6
- * Render a React element to its initial HTML. This should only be used on the server.
7
- * React will return an HTML string. You can use this method to generate HTML on the server
8
- * and send the markup down on the initial request for faster page loads and to allow search
9
- * engines to crawl your pages for SEO purposes.
10
- *
11
- * If you call `ReactDOM.render()` on a node that already has this server-rendered markup,
12
- * React will preserve it and only attach event handlers, allowing you
13
- * to have a very performant first-load experience.
14
- */
15
- export function renderToString(element: ReactElement<any>): string;
16
-
17
- /**
18
- * Render a React element to its initial HTML. Returns a Readable stream that outputs
19
- * an HTML string. The HTML output by this stream is exactly equal to what
20
- * `ReactDOMServer.renderToString()` would return.
21
- */
22
- export function renderToNodeStream(element: ReactElement<any>): NodeJS.ReadableStream;
23
-
24
- /**
25
- * Similar to `renderToString`, except this doesn't create extra DOM attributes
26
- * such as `data-reactid`, that React uses internally. This is useful if you want
27
- * to use React as a simple static page generator, as stripping away the extra
28
- * attributes can save lots of bytes.
29
- */
30
- export function renderToStaticMarkup(element: ReactElement<any>): string;
31
-
32
- /**
33
- * Similar to `renderToNodeStream`, except this doesn't create extra DOM attributes
34
- * such as `data-reactid`, that React uses internally. The HTML output by this stream
35
- * is exactly equal to what `ReactDOMServer.renderToStaticMarkup()` would return.
36
- */
37
- export function renderToStaticNodeStream(element: ReactElement<any>): NodeJS.ReadableStream;
38
-
39
- export const version: string;
40
-
41
- export as namespace ReactDOMServer;
1
+ // forward declarations
2
+ declare global {
3
+ namespace NodeJS {
4
+ // tslint:disable-next-line:no-empty-interface
5
+ interface ReadableStream {}
6
+ }
7
+ }
8
+
9
+ import { ReactElement } from 'react';
10
+
11
+ /**
12
+ * Render a React element to its initial HTML. This should only be used on the server.
13
+ * React will return an HTML string. You can use this method to generate HTML on the server
14
+ * and send the markup down on the initial request for faster page loads and to allow search
15
+ * engines to crawl your pages for SEO purposes.
16
+ *
17
+ * If you call `ReactDOM.render()` on a node that already has this server-rendered markup,
18
+ * React will preserve it and only attach event handlers, allowing you
19
+ * to have a very performant first-load experience.
20
+ */
21
+ export function renderToString(element: ReactElement<any>): string;
22
+
23
+ /**
24
+ * Render a React element to its initial HTML. Returns a Readable stream that outputs
25
+ * an HTML string. The HTML output by this stream is exactly equal to what
26
+ * `ReactDOMServer.renderToString()` would return.
27
+ */
28
+ export function renderToNodeStream(element: ReactElement<any>): NodeJS.ReadableStream;
29
+
30
+ /**
31
+ * Similar to `renderToString`, except this doesn't create extra DOM attributes
32
+ * such as `data-reactid`, that React uses internally. This is useful if you want
33
+ * to use React as a simple static page generator, as stripping away the extra
34
+ * attributes can save lots of bytes.
35
+ */
36
+ export function renderToStaticMarkup(element: ReactElement<any>): string;
37
+
38
+ /**
39
+ * Similar to `renderToNodeStream`, except this doesn't create extra DOM attributes
40
+ * such as `data-reactid`, that React uses internally. The HTML output by this stream
41
+ * is exactly equal to what `ReactDOMServer.renderToStaticMarkup()` would return.
42
+ */
43
+ export function renderToStaticNodeStream(element: ReactElement<any>): NodeJS.ReadableStream;
44
+
45
+ export const version: string;
46
+
47
+ export as namespace ReactDOMServer;
@@ -1,276 +1,303 @@
1
- import {
2
- AbstractView, Component, ComponentClass,
3
- ReactElement, ReactInstance, ClassType,
4
- DOMElement, SFCElement, CElement,
5
- ReactHTMLElement, DOMAttributes, SFC
6
- } from 'react';
7
-
8
- import * as ReactTestUtils from ".";
9
-
10
- export interface OptionalEventProperties {
11
- bubbles?: boolean;
12
- cancelable?: boolean;
13
- currentTarget?: EventTarget;
14
- defaultPrevented?: boolean;
15
- eventPhase?: number;
16
- isTrusted?: boolean;
17
- nativeEvent?: Event;
18
- preventDefault?(): void;
19
- stopPropagation?(): void;
20
- target?: EventTarget;
21
- timeStamp?: Date;
22
- type?: string;
23
- }
24
-
25
- export interface SyntheticEventData extends OptionalEventProperties {
26
- altKey?: boolean;
27
- button?: number;
28
- buttons?: number;
29
- clientX?: number;
30
- clientY?: number;
31
- changedTouches?: TouchList;
32
- charCode?: boolean;
33
- clipboardData?: DataTransfer;
34
- ctrlKey?: boolean;
35
- deltaMode?: number;
36
- deltaX?: number;
37
- deltaY?: number;
38
- deltaZ?: number;
39
- detail?: number;
40
- getModifierState?(key: string): boolean;
41
- key?: string;
42
- keyCode?: number;
43
- locale?: string;
44
- location?: number;
45
- metaKey?: boolean;
46
- pageX?: number;
47
- pageY?: number;
48
- relatedTarget?: EventTarget;
49
- repeat?: boolean;
50
- screenX?: number;
51
- screenY?: number;
52
- shiftKey?: boolean;
53
- targetTouches?: TouchList;
54
- touches?: TouchList;
55
- view?: AbstractView;
56
- which?: number;
57
- }
58
-
59
- export type EventSimulator = (element: Element | Component<any>, eventData?: SyntheticEventData) => void;
60
-
61
- export interface MockedComponentClass {
62
- new (props: {}): any;
63
- }
64
-
65
- export interface ShallowRenderer {
66
- /**
67
- * After `shallowRenderer.render()` has been called, returns shallowly rendered output.
68
- */
69
- getRenderOutput<E extends ReactElement<any>>(): E;
70
- /**
71
- * After `shallowRenderer.render()` has been called, returns shallowly rendered output.
72
- */
73
- getRenderOutput(): ReactElement<any>;
74
- /**
75
- * Similar to `ReactDOM.render` but it doesn't require DOM and only renders a single level deep.
76
- */
77
- render(element: ReactElement<any>, context?: any): void;
78
- unmount(): void;
79
- }
80
-
81
- /**
82
- * Simulate an event dispatch on a DOM node with optional `eventData` event data.
83
- * `Simulate` has a method for every event that React understands.
84
- */
85
- export namespace Simulate {
86
- const abort: EventSimulator;
87
- const animationEnd: EventSimulator;
88
- const animationIteration: EventSimulator;
89
- const animationStart: EventSimulator;
90
- const blur: EventSimulator;
91
- const canPlay: EventSimulator;
92
- const canPlayThrough: EventSimulator;
93
- const change: EventSimulator;
94
- const click: EventSimulator;
95
- const compositionEnd: EventSimulator;
96
- const compositionStart: EventSimulator;
97
- const compositionUpdate: EventSimulator;
98
- const contextMenu: EventSimulator;
99
- const copy: EventSimulator;
100
- const cut: EventSimulator;
101
- const doubleClick: EventSimulator;
102
- const drag: EventSimulator;
103
- const dragEnd: EventSimulator;
104
- const dragEnter: EventSimulator;
105
- const dragExit: EventSimulator;
106
- const dragLeave: EventSimulator;
107
- const dragOver: EventSimulator;
108
- const dragStart: EventSimulator;
109
- const drop: EventSimulator;
110
- const durationChange: EventSimulator;
111
- const emptied: EventSimulator;
112
- const encrypted: EventSimulator;
113
- const ended: EventSimulator;
114
- const error: EventSimulator;
115
- const focus: EventSimulator;
116
- const input: EventSimulator;
117
- const invalid: EventSimulator;
118
- const keyDown: EventSimulator;
119
- const keyPress: EventSimulator;
120
- const keyUp: EventSimulator;
121
- const load: EventSimulator;
122
- const loadStart: EventSimulator;
123
- const loadedData: EventSimulator;
124
- const loadedMetadata: EventSimulator;
125
- const mouseDown: EventSimulator;
126
- const mouseEnter: EventSimulator;
127
- const mouseLeave: EventSimulator;
128
- const mouseMove: EventSimulator;
129
- const mouseOut: EventSimulator;
130
- const mouseOver: EventSimulator;
131
- const mouseUp: EventSimulator;
132
- const paste: EventSimulator;
133
- const pause: EventSimulator;
134
- const play: EventSimulator;
135
- const playing: EventSimulator;
136
- const progress: EventSimulator;
137
- const rateChange: EventSimulator;
138
- const scroll: EventSimulator;
139
- const seeked: EventSimulator;
140
- const seeking: EventSimulator;
141
- const select: EventSimulator;
142
- const stalled: EventSimulator;
143
- const submit: EventSimulator;
144
- const suspend: EventSimulator;
145
- const timeUpdate: EventSimulator;
146
- const touchCancel: EventSimulator;
147
- const touchEnd: EventSimulator;
148
- const touchMove: EventSimulator;
149
- const touchStart: EventSimulator;
150
- const transitionEnd: EventSimulator;
151
- const volumeChange: EventSimulator;
152
- const waiting: EventSimulator;
153
- const wheel: EventSimulator;
154
- }
155
-
156
- /**
157
- * Render a React element into a detached DOM node in the document. __This function requires a DOM__.
158
- */
159
- export function renderIntoDocument<T extends Element>(
160
- element: DOMElement<any, T>): T;
161
- export function renderIntoDocument(
162
- element: SFCElement<any>): void;
163
- export function renderIntoDocument<T extends Component<any>>(
164
- element: CElement<any, T>): T;
165
- export function renderIntoDocument<P>(
166
- element: ReactElement<P>): Component<P> | Element | void;
167
-
168
- /**
169
- * Pass a mocked component module to this method to augment it with useful methods that allow it to
170
- * be used as a dummy React component. Instead of rendering as usual, the component will become
171
- * a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
172
- */
173
- export function mockComponent(
174
- mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils;
175
-
176
- /**
177
- * Returns `true` if `element` is any React element.
178
- */
179
- export function isElement(element: any): boolean;
180
-
181
- /**
182
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
183
- */
184
- export function isElementOfType<T extends HTMLElement>(
185
- element: ReactElement<any>, type: string): element is ReactHTMLElement<T>;
186
- /**
187
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
188
- */
189
- export function isElementOfType<P extends DOMAttributes<{}>, T extends Element>(
190
- element: ReactElement<any>, type: string): element is DOMElement<P, T>;
191
- /**
192
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
193
- */
194
- export function isElementOfType<P>(
195
- element: ReactElement<any>, type: SFC<P>): element is SFCElement<P>;
196
- /**
197
- * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
198
- */
199
- export function isElementOfType<P, T extends Component<P>, C extends ComponentClass<P>>(
200
- element: ReactElement<any>, type: ClassType<P, T, C>): element is CElement<P, T>;
201
-
202
- /**
203
- * Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
204
- */
205
- export function isDOMComponent(instance: ReactInstance): instance is Element;
206
- /**
207
- * Returns `true` if `instance` is a user-defined component, such as a class or a function.
208
- */
209
- export function isCompositeComponent(instance: ReactInstance): instance is Component<any>;
210
- /**
211
- * Returns `true` if `instance` is a component whose type is of a React `componentClass`.
212
- */
213
- export function isCompositeComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
214
- instance: ReactInstance, type: ClassType<any, T, C>): boolean;
215
-
216
- /**
217
- * Traverse all components in `tree` and accumulate all components where
218
- * `test(component)` is `true`. This is not that useful on its own, but it's used
219
- * as a primitive for other test utils.
220
- */
221
- export function findAllInRenderedTree(
222
- root: Component<any>,
223
- fn: (i: ReactInstance) => boolean): ReactInstance[];
224
-
225
- /**
226
- * Finds all DOM elements of components in the rendered tree that are
227
- * DOM components with the class name matching `className`.
228
- */
229
- export function scryRenderedDOMComponentsWithClass(
230
- root: Component<any>,
231
- className: string): Element[];
232
- /**
233
- * Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
234
- * and returns that one result, or throws exception if there is any other
235
- * number of matches besides one.
236
- */
237
- export function findRenderedDOMComponentWithClass(
238
- root: Component<any>,
239
- className: string): Element;
240
-
241
- /**
242
- * Finds all DOM elements of components in the rendered tree that are
243
- * DOM components with the tag name matching `tagName`.
244
- */
245
- export function scryRenderedDOMComponentsWithTag(
246
- root: Component<any>,
247
- tagName: string): Element[];
248
- /**
249
- * Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result,
250
- * and returns that one result, or throws exception if there is any other
251
- * number of matches besides one.
252
- */
253
- export function findRenderedDOMComponentWithTag(
254
- root: Component<any>,
255
- tagName: string): Element;
256
-
257
- /**
258
- * Finds all instances of components with type equal to `componentClass`.
259
- */
260
- export function scryRenderedComponentsWithType<T extends Component, C extends ComponentClass>(
261
- root: Component<any>,
262
- type: ClassType<any, T, C>): T[];
263
-
264
- /**
265
- * Same as `scryRenderedComponentsWithType()` but expects there to be one result
266
- * and returns that one result, or throws exception if there is any other
267
- * number of matches besides one.
268
- */
269
- export function findRenderedComponentWithType<T extends Component, C extends ComponentClass>(
270
- root: Component<any>,
271
- type: ClassType<any, T, C>): T;
272
-
273
- /**
274
- * Call this in your tests to create a shallow renderer.
275
- */
276
- export function createRenderer(): ShallowRenderer;
1
+ import {
2
+ AbstractView, Component, ComponentClass,
3
+ ReactElement, ReactInstance, ClassType,
4
+ DOMElement, SFCElement, CElement,
5
+ ReactHTMLElement, DOMAttributes, SFC
6
+ } from 'react';
7
+
8
+ import * as ReactTestUtils from ".";
9
+
10
+ export interface OptionalEventProperties {
11
+ bubbles?: boolean;
12
+ cancelable?: boolean;
13
+ currentTarget?: EventTarget;
14
+ defaultPrevented?: boolean;
15
+ eventPhase?: number;
16
+ isTrusted?: boolean;
17
+ nativeEvent?: Event;
18
+ preventDefault?(): void;
19
+ stopPropagation?(): void;
20
+ target?: EventTarget;
21
+ timeStamp?: Date;
22
+ type?: string;
23
+ }
24
+
25
+ export interface SyntheticEventData extends OptionalEventProperties {
26
+ altKey?: boolean;
27
+ button?: number;
28
+ buttons?: number;
29
+ clientX?: number;
30
+ clientY?: number;
31
+ changedTouches?: TouchList;
32
+ charCode?: boolean;
33
+ clipboardData?: DataTransfer;
34
+ ctrlKey?: boolean;
35
+ deltaMode?: number;
36
+ deltaX?: number;
37
+ deltaY?: number;
38
+ deltaZ?: number;
39
+ detail?: number;
40
+ getModifierState?(key: string): boolean;
41
+ key?: string;
42
+ keyCode?: number;
43
+ locale?: string;
44
+ location?: number;
45
+ metaKey?: boolean;
46
+ pageX?: number;
47
+ pageY?: number;
48
+ relatedTarget?: EventTarget;
49
+ repeat?: boolean;
50
+ screenX?: number;
51
+ screenY?: number;
52
+ shiftKey?: boolean;
53
+ targetTouches?: TouchList;
54
+ touches?: TouchList;
55
+ view?: AbstractView;
56
+ which?: number;
57
+ }
58
+
59
+ export type EventSimulator = (element: Element | Component<any>, eventData?: SyntheticEventData) => void;
60
+
61
+ export interface MockedComponentClass {
62
+ new (props: any): any;
63
+ }
64
+
65
+ export interface ShallowRenderer {
66
+ /**
67
+ * After `shallowRenderer.render()` has been called, returns shallowly rendered output.
68
+ */
69
+ getRenderOutput<E extends ReactElement<any>>(): E;
70
+ /**
71
+ * After `shallowRenderer.render()` has been called, returns shallowly rendered output.
72
+ */
73
+ getRenderOutput(): ReactElement<any>;
74
+ /**
75
+ * Similar to `ReactDOM.render` but it doesn't require DOM and only renders a single level deep.
76
+ */
77
+ render(element: ReactElement<any>, context?: any): void;
78
+ unmount(): void;
79
+ }
80
+
81
+ /**
82
+ * Simulate an event dispatch on a DOM node with optional `eventData` event data.
83
+ * `Simulate` has a method for every event that React understands.
84
+ */
85
+ export namespace Simulate {
86
+ const abort: EventSimulator;
87
+ const animationEnd: EventSimulator;
88
+ const animationIteration: EventSimulator;
89
+ const animationStart: EventSimulator;
90
+ const blur: EventSimulator;
91
+ const canPlay: EventSimulator;
92
+ const canPlayThrough: EventSimulator;
93
+ const change: EventSimulator;
94
+ const click: EventSimulator;
95
+ const compositionEnd: EventSimulator;
96
+ const compositionStart: EventSimulator;
97
+ const compositionUpdate: EventSimulator;
98
+ const contextMenu: EventSimulator;
99
+ const copy: EventSimulator;
100
+ const cut: EventSimulator;
101
+ const doubleClick: EventSimulator;
102
+ const drag: EventSimulator;
103
+ const dragEnd: EventSimulator;
104
+ const dragEnter: EventSimulator;
105
+ const dragExit: EventSimulator;
106
+ const dragLeave: EventSimulator;
107
+ const dragOver: EventSimulator;
108
+ const dragStart: EventSimulator;
109
+ const drop: EventSimulator;
110
+ const durationChange: EventSimulator;
111
+ const emptied: EventSimulator;
112
+ const encrypted: EventSimulator;
113
+ const ended: EventSimulator;
114
+ const error: EventSimulator;
115
+ const focus: EventSimulator;
116
+ const input: EventSimulator;
117
+ const invalid: EventSimulator;
118
+ const keyDown: EventSimulator;
119
+ const keyPress: EventSimulator;
120
+ const keyUp: EventSimulator;
121
+ const load: EventSimulator;
122
+ const loadStart: EventSimulator;
123
+ const loadedData: EventSimulator;
124
+ const loadedMetadata: EventSimulator;
125
+ const mouseDown: EventSimulator;
126
+ const mouseEnter: EventSimulator;
127
+ const mouseLeave: EventSimulator;
128
+ const mouseMove: EventSimulator;
129
+ const mouseOut: EventSimulator;
130
+ const mouseOver: EventSimulator;
131
+ const mouseUp: EventSimulator;
132
+ const paste: EventSimulator;
133
+ const pause: EventSimulator;
134
+ const play: EventSimulator;
135
+ const playing: EventSimulator;
136
+ const progress: EventSimulator;
137
+ const rateChange: EventSimulator;
138
+ const scroll: EventSimulator;
139
+ const seeked: EventSimulator;
140
+ const seeking: EventSimulator;
141
+ const select: EventSimulator;
142
+ const stalled: EventSimulator;
143
+ const submit: EventSimulator;
144
+ const suspend: EventSimulator;
145
+ const timeUpdate: EventSimulator;
146
+ const touchCancel: EventSimulator;
147
+ const touchEnd: EventSimulator;
148
+ const touchMove: EventSimulator;
149
+ const touchStart: EventSimulator;
150
+ const transitionEnd: EventSimulator;
151
+ const volumeChange: EventSimulator;
152
+ const waiting: EventSimulator;
153
+ const wheel: EventSimulator;
154
+ }
155
+
156
+ /**
157
+ * Render a React element into a detached DOM node in the document. __This function requires a DOM__.
158
+ */
159
+ export function renderIntoDocument<T extends Element>(
160
+ element: DOMElement<any, T>): T;
161
+ export function renderIntoDocument(
162
+ element: SFCElement<any>): void;
163
+ // If we replace `P` with `any` in this overload, then some tests fail because
164
+ // calls to `renderIntoDocument` choose the last overload on the
165
+ // subtype-relation pass and get an undesirably broad return type. Using `P`
166
+ // allows this overload to match on the subtype-relation pass.
167
+ export function renderIntoDocument<P, T extends Component<P>>(
168
+ element: CElement<P, T>): T;
169
+ export function renderIntoDocument<P>(
170
+ element: ReactElement<P>): Component<P> | Element | void;
171
+
172
+ /**
173
+ * Pass a mocked component module to this method to augment it with useful methods that allow it to
174
+ * be used as a dummy React component. Instead of rendering as usual, the component will become
175
+ * a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
176
+ */
177
+ export function mockComponent(
178
+ mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils;
179
+
180
+ /**
181
+ * Returns `true` if `element` is any React element.
182
+ */
183
+ export function isElement(element: any): boolean;
184
+
185
+ /**
186
+ * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
187
+ */
188
+ export function isElementOfType<T extends HTMLElement>(
189
+ element: ReactElement<any>, type: string): element is ReactHTMLElement<T>;
190
+ /**
191
+ * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
192
+ */
193
+ export function isElementOfType<P extends DOMAttributes<{}>, T extends Element>(
194
+ element: ReactElement<any>, type: string): element is DOMElement<P, T>;
195
+ /**
196
+ * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
197
+ */
198
+ export function isElementOfType<P>(
199
+ element: ReactElement<any>, type: SFC<P>): element is SFCElement<P>;
200
+ /**
201
+ * Returns `true` if `element` is a React element whose type is of a React `componentClass`.
202
+ */
203
+ export function isElementOfType<P, T extends Component<P>, C extends ComponentClass<P>>(
204
+ element: ReactElement<any>, type: ClassType<P, T, C>): element is CElement<P, T>;
205
+
206
+ /**
207
+ * Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
208
+ */
209
+ export function isDOMComponent(instance: ReactInstance): instance is Element;
210
+ /**
211
+ * Returns `true` if `instance` is a user-defined component, such as a class or a function.
212
+ */
213
+ export function isCompositeComponent(instance: ReactInstance): instance is Component<any>;
214
+ /**
215
+ * Returns `true` if `instance` is a component whose type is of a React `componentClass`.
216
+ */
217
+ export function isCompositeComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
218
+ instance: ReactInstance, type: ClassType<any, T, C>): boolean;
219
+
220
+ /**
221
+ * Traverse all components in `tree` and accumulate all components where
222
+ * `test(component)` is `true`. This is not that useful on its own, but it's used
223
+ * as a primitive for other test utils.
224
+ */
225
+ export function findAllInRenderedTree(
226
+ root: Component<any>,
227
+ fn: (i: ReactInstance) => boolean): ReactInstance[];
228
+
229
+ /**
230
+ * Finds all DOM elements of components in the rendered tree that are
231
+ * DOM components with the class name matching `className`.
232
+ */
233
+ export function scryRenderedDOMComponentsWithClass(
234
+ root: Component<any>,
235
+ className: string): Element[];
236
+ /**
237
+ * Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
238
+ * and returns that one result, or throws exception if there is any other
239
+ * number of matches besides one.
240
+ */
241
+ export function findRenderedDOMComponentWithClass(
242
+ root: Component<any>,
243
+ className: string): Element;
244
+
245
+ /**
246
+ * Finds all DOM elements of components in the rendered tree that are
247
+ * DOM components with the tag name matching `tagName`.
248
+ */
249
+ export function scryRenderedDOMComponentsWithTag(
250
+ root: Component<any>,
251
+ tagName: string): Element[];
252
+ /**
253
+ * Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result,
254
+ * and returns that one result, or throws exception if there is any other
255
+ * number of matches besides one.
256
+ */
257
+ export function findRenderedDOMComponentWithTag(
258
+ root: Component<any>,
259
+ tagName: string): Element;
260
+
261
+ /**
262
+ * Finds all instances of components with type equal to `componentClass`.
263
+ */
264
+ export function scryRenderedComponentsWithType<T extends Component<any>, C extends ComponentClass<any>>(
265
+ root: Component<any>,
266
+ type: ClassType<any, T, C>): T[];
267
+
268
+ /**
269
+ * Same as `scryRenderedComponentsWithType()` but expects there to be one result
270
+ * and returns that one result, or throws exception if there is any other
271
+ * number of matches besides one.
272
+ */
273
+ export function findRenderedComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
274
+ root: Component<any>,
275
+ type: ClassType<any, T, C>): T;
276
+
277
+ /**
278
+ * Call this in your tests to create a shallow renderer.
279
+ */
280
+ export function createRenderer(): ShallowRenderer;
281
+
282
+ /**
283
+ * Wrap any code rendering and triggering updates to your components into `act()` calls.
284
+ *
285
+ * Ensures that the behavior in your tests matches what happens in the browser
286
+ * more closely by executing pending `useEffect`s before returning. This also
287
+ * reduces the amount of re-renders done.
288
+ *
289
+ * @param callback A synchronous, void callback that will execute as a single, complete React commit.
290
+ *
291
+ * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
292
+ */
293
+ // the "void | undefined" is here to forbid any sneaky "Promise" returns.
294
+ // the actual return value is always a "DebugPromiseLike",
295
+ // but having an "| {}" makes it harder to accidentally use.
296
+ export function act(callback: () => void | undefined): DebugPromiseLike | {};
297
+
298
+ // Intentionally doesn't extend PromiseLike<never>.
299
+ // Ideally this should be as hard to accidentally use as possible.
300
+ export interface DebugPromiseLike {
301
+ // the actual then() in here is 0-ary, but that doesn't count as a PromiseLike.
302
+ then(onfulfilled: (value: never) => never, onrejected: (reason: never) => never): never;
303
+ }