Skip to content

Commit

Permalink
fix: one step closer to fixing types in jest wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Aug 31, 2024
1 parent a97d811 commit b69f595
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/jest/src/jest-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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,10 +111,10 @@ expect.extend({
},
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function scopeExpectationFunctionToMethod<Args extends any[]>(
func: (...args: Args) => SyncExpectationResult,
function scopeExpectationFunctionToMethod<Fn extends (...args: any[]) => SyncExpectationResult>(
func: Fn,
method: string,
): (...args: Args) => SyncExpectationResult {
): (...args: Parameters<Fn>) => SyncExpectationResult {
return (...args) => {
const opts = args[func.length - 1] || {};
args[func.length - 1] = { ...opts, method };
Expand All @@ -138,8 +139,7 @@ function scopeExpectationNameToMethod(name: string, humanVerb: string): string {
const extensions = Object.fromEntries(
Object.entries(methodlessExtensions).map(([name, func]) => [
scopeExpectationNameToMethod(name, humanVerb),
//@ts-expect-error Still need to work on getting the generics here correct
scopeExpectationFunctionToMethod(func, method),
scopeExpectationFunctionToMethod(func, method) ,
]),
);

Expand Down

0 comments on commit b69f595

Please sign in to comment.