mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
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:
committed by
Sheetal Nandi
parent
f0708acb4b
commit
4b81edcaf8
Vendored
+1
-1
@@ -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>
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-type-assertion": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user