Skip to content

Commit

Permalink
fix: applied same type fixes to vitest wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Aug 31, 2024
1 parent 2ab6f0d commit 817af39
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/vitest/src/vitest-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ expect.extend({
};
},
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function scopeExpectationFunctionToMethod<Args extends any[]>(
func: (...args: Args) => SyncExpectationResult,

function scopeExpectationFunctionToMethod<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
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 @@ -136,10 +139,12 @@ 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),
//@ts-expect-error awaiting this fix https://github.com/vitest-dev/vitest/pull/6351
scopeExpectationFunctionToMethod(func, method),
]),
);
Expand Down

0 comments on commit 817af39

Please sign in to comment.