Skip to content

Commit

Permalink
chore: types for jest wrapper now all pass
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Aug 31, 2024
1 parent b69f595 commit 2ab6f0d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/jest/src/jest-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@jest/globals';
import type { SyncExpectationResult } from 'expect';
import fetchMock from '@fetch-mock/core';
import type {
FetchMock,
RouteName,
Expand Down Expand Up @@ -110,8 +109,11 @@ expect.extend({
};
},
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function scopeExpectationFunctionToMethod<Fn extends (...args: any[]) => SyncExpectationResult>(

function scopeExpectationFunctionToMethod<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Fn extends (...args: any[]) => SyncExpectationResult,
>(
func: Fn,
method: string,
): (...args: Parameters<Fn>) => SyncExpectationResult {
Expand All @@ -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),
]),
);

Expand Down

0 comments on commit 2ab6f0d

Please sign in to comment.