From c1f2957a219ec7e6a6159a57c5d0717655c515cd Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 7 May 2024 13:07:04 +0200 Subject: [PATCH] fix: Ensure `act` is not `any` when `React.act` is not declared (#1323) --- types/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index c1cb345f..37c8392a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -251,6 +251,7 @@ export function cleanup(): void * If that's not available (older version of react) then it * simply calls the deprecated version which is ReactTestUtils.act(cb) */ -export const act: typeof reactAct extends never +// IfAny from https://stackoverflow.com/a/61626123/3406963 +export const act: 0 extends 1 & typeof reactAct ? typeof reactDeprecatedAct : typeof reactAct