You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm converting from jest.spyOn(google, "sheets").mockReturnValue({}); to vi.spyOn(google, "sheets").mockReturnValue({}); and it doesn't work - says that "sheets" is not assignable to "never".
Using the following patch (inspired by MethodLikeKeys from jest types) solves the issue:
diff --git a/node_modules/@vitest/spy/dist/index.d.ts b/node_modules/@vitest/spy/dist/index.d.ts
index ad13b9b..5428415 100644
--- a/node_modules/@vitest/spy/dist/index.d.ts+++ b/node_modules/@vitest/spy/dist/index.d.ts@@ -21,9 +21,9 @@ interface MockContext<TArgs, TReturns> {
lastCall: TArgs | undefined;
}
type Procedure = (...args: any[]) => any;
-type Methods<T> = {- [K in keyof T]: T[K] extends Procedure ? K : never;-}[keyof T] & (string | symbol);+type Methods<T> = keyof {+ [K in keyof T as T[K] extends Procedure ? K : never]: T[K];+};
type Properties<T> = {
[K in keyof T]: T[K] extends Procedure ? never : K;
}[keyof T] & (string | symbol);
Describe the bug
I'm converting from
jest.spyOn(google, "sheets").mockReturnValue({});
tovi.spyOn(google, "sheets").mockReturnValue({});
and it doesn't work - says that "sheets" is not assignable to "never".Using the following patch (inspired by
MethodLikeKeys
from jest types) solves the issue:This might be related: DefinitelyTyped/DefinitelyTyped#63182
Reproduction
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: