Skip to content

Commit 6a3390c

Browse files
Merge pull request #31271 from storybookjs/valentin/remove-vitest-2-workarounds
Test: Remove legacy code
2 parents 17b8ed7 + e2751b5 commit 6a3390c

File tree

3 files changed

+3
-20
lines changed
  • code
    • core/src/test
    • frameworks
      • nextjs/src/export-mocks/navigation
      • nextjs-vite/src/export-mocks/navigation

3 files changed

+3
-20
lines changed

code/core/src/test/spy.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MockInstance, Mock as MockV2 } from '@vitest/spy';
1+
import type { Mock, MockInstance } from '@vitest/spy';
22
import {
33
type MaybeMocked,
44
type MaybeMockedDeep,
@@ -33,24 +33,7 @@ export const spyOn: typeof vitestSpyOn = (...args) => {
3333

3434
type Procedure = (...args: any[]) => any;
3535

36-
// TODO: Remove in 9.0
37-
export type Mock<T extends Procedure | any[] = any[], R = any> = T extends Procedure
38-
? MockV2<T>
39-
: T extends any[]
40-
? MockV2<(...args: T) => R>
41-
: never;
42-
43-
// V2
4436
export function fn<T extends Procedure = Procedure>(implementation?: T): Mock<T>;
45-
// TODO: Remove in 9.0
46-
// V1
47-
export function fn<TArgs extends any[] = any, R = any>(): Mock<(...args: TArgs) => R>;
48-
export function fn<TArgs extends any[] = any[], R = any>(
49-
implementation: (...args: TArgs) => R
50-
): Mock<(...args: TArgs) => R>;
51-
export function fn<TArgs extends any[] = any[], R = any>(
52-
implementation?: (...args: TArgs) => R
53-
): Mock<(...args: TArgs) => R>;
5437
export function fn(implementation?: Procedure) {
5538
const mock = implementation ? vitestFn(implementation) : vitestFn();
5639
return reactiveMock(mock);

code/frameworks/nextjs-vite/src/export-mocks/navigation/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ export const notFound = fn(actual.notFound).mockName('next/navigation::notFound'
9393
interface Params {
9494
[key: string]: string | string[];
9595
}
96-
export const useParams = fn<[], Params>(actual.useParams).mockName('next/navigation::useParams');
96+
export const useParams = fn<() => Params>(actual.useParams).mockName('next/navigation::useParams');

code/frameworks/nextjs/src/export-mocks/navigation/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ export const notFound = fn(actual.notFound).mockName('next/navigation::notFound'
9393
interface Params {
9494
[key: string]: string | string[];
9595
}
96-
export const useParams = fn<[], Params>(actual.useParams).mockName('next/navigation::useParams');
96+
export const useParams = fn<() => Params>(actual.useParams).mockName('next/navigation::useParams');

0 commit comments

Comments
 (0)