From 346eb21092324d85c2547dd92f5ae1349f826e7a Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Mon, 12 Aug 2019 09:37:09 +0200 Subject: [PATCH 1/2] fix(types): Use act types from react-dom --- package.json | 3 ++- typings/index.d.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 279e065e..ff29c1af 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.5.5", - "@testing-library/dom": "^6.0.0" + "@testing-library/dom": "^6.0.0", + "@types/react-dom": "*" }, "devDependencies": { "@reach/router": "^1.2.1", diff --git a/typings/index.d.ts b/typings/index.d.ts index ddc5512a..bfbda4e9 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,4 +1,5 @@ import {queries, Queries, BoundFunction} from '@testing-library/dom' +import {act as reactAct} from 'react-dom/test-utils' export * from '@testing-library/dom' @@ -43,4 +44,6 @@ export function cleanup(): void * If that's not available (older version of react) then it * simply calls the given callback immediately */ -export function act(callback: () => void): void +export const act: typeof reactAct extends () => any + ? typeof reactAct + : (callback: () => void) => void From 1c4805938b2ee62ba31046df88bb6ee7323b6cbc Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Mon, 12 Aug 2019 09:42:59 +0200 Subject: [PATCH 2/2] Fix unary not extending binary --- typings/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index bfbda4e9..ab4528e2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -44,6 +44,6 @@ export function cleanup(): void * If that's not available (older version of react) then it * simply calls the given callback immediately */ -export const act: typeof reactAct extends () => any - ? typeof reactAct - : (callback: () => void) => void +export const act: typeof reactAct extends undefined + ? (callback: () => void) => void + : typeof reactAct