feat(react-dom): Add async act (#37554)

* feat(react-dom): Add async act typings

* Update version

* Normalize typing with react-test-renderer
This commit is contained in:
Sebastian Silbermann
2019-08-19 13:02:30 -07:00
committed by Sheetal Nandi
parent f0708acb4b
commit 4b81edcaf8
4 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for React (react-dom) 16.8
// Type definitions for React (react-dom) 16.9
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
+2 -3
View File
@@ -185,9 +185,8 @@ describe('React dom test utils', () => {
it('accepts a sync callback that is void', () => {
ReactTestUtils.act(() => {});
});
it('rejects an async callback even if void', () => {
// $ExpectError
ReactTestUtils.act(async () => {});
it('accepts an async callback that is void', async () => {
await ReactTestUtils.act(async () => {});
});
it('rejects a callback that returns null', () => {
// $ExpectError
+3 -1
View File
@@ -291,8 +291,10 @@ export function createRenderer(): ShallowRenderer;
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
*/
// the "void | undefined" is here to forbid any sneaky "Promise" returns.
// the actual return value is always a "DebugPromiseLike".
export function act(callback: () => void | undefined): DebugPromiseLike;
// the "void | undefined" is here to forbid any sneaky return values
// tslint:disable-next-line: void-return
export function act(callback: () => Promise<void | undefined>): Promise<undefined>;
// Intentionally doesn't extend PromiseLike<never>.
// Ideally this should be as hard to accidentally use as possible.
+1 -1
View File
@@ -7,4 +7,4 @@
"no-unnecessary-generics": false,
"no-unnecessary-type-assertion": false
}
}
}