From 2ab6f0d4de37098db47ea91e744bc29e56e67cf7 Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Sat, 31 Aug 2024 13:26:16 +0100 Subject: [PATCH] chore: types for jest wrapper now all pass --- packages/jest/src/jest-extensions.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/jest/src/jest-extensions.ts b/packages/jest/src/jest-extensions.ts index 71b22999..59b8bacb 100644 --- a/packages/jest/src/jest-extensions.ts +++ b/packages/jest/src/jest-extensions.ts @@ -1,6 +1,5 @@ import { expect } from '@jest/globals'; import type { SyncExpectationResult } from 'expect'; -import fetchMock from '@fetch-mock/core'; import type { FetchMock, RouteName, @@ -110,8 +109,11 @@ expect.extend({ }; }, }); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function scopeExpectationFunctionToMethod SyncExpectationResult>( + +function scopeExpectationFunctionToMethod< + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Fn extends (...args: any[]) => SyncExpectationResult, +>( func: Fn, method: string, ): (...args: Parameters) => SyncExpectationResult { @@ -136,10 +138,13 @@ function scopeExpectationNameToMethod(name: string, humanVerb: string): string { ].forEach((verbs) => { const [humanVerb, method] = verbs.split(':'); - const extensions = Object.fromEntries( + const extensions: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: (...args: any[]) => SyncExpectationResult; + } = Object.fromEntries( Object.entries(methodlessExtensions).map(([name, func]) => [ scopeExpectationNameToMethod(name, humanVerb), - scopeExpectationFunctionToMethod(func, method) , + scopeExpectationFunctionToMethod(func, method), ]), );