Skip to content

Commit e5c388f

Browse files
authored
fix(vitest,runner): simplify test.extend type exports (#6707)
1 parent 62ac4eb commit e5c388f

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

packages/runner/src/types/tasks.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,11 @@ interface ExtendedAPI<ExtraContext> {
411411
runIf: (condition: any) => ChainableTestAPI<ExtraContext>
412412
}
413413

414-
export type CustomAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> &
414+
export type TestAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> &
415415
ExtendedAPI<ExtraContext> & {
416416
extend: <T extends Record<string, any> = object>(
417417
fixtures: Fixtures<T, ExtraContext>
418-
) => CustomAPI<{
418+
) => TestAPI<{
419419
[K in keyof T | keyof ExtraContext]: K extends keyof T
420420
? T[K]
421421
: K extends keyof ExtraContext
@@ -424,7 +424,7 @@ export type CustomAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> &
424424
}>
425425
}
426426

427-
export type TestAPI<ExtraContext = object> = CustomAPI<ExtraContext>
427+
export type { TestAPI as CustomAPI }
428428

429429
export interface FixtureOptions {
430430
/**

pnpm-lock.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/dts-fixture/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "@vitest/test-dts-fixture",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"build": "rm -rf dist && tsc -p tsconfig.json",
7+
"check": "tsc -p tsconfig.check.json",
8+
"test": "pnpm build && pnpm check"
9+
},
10+
"devDependencies": {
11+
"vitest": "workspace:*"
12+
}
13+
}

test/dts-fixture/src/repro.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test } from 'vitest'
2+
3+
export const myTest = test.extend<{ now: number }>({
4+
now: async ({}, use) => {
5+
await use(Date.now())
6+
},
7+
})

test/dts-fixture/tsconfig.check.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"types": [],
7+
"strict": true,
8+
"noEmit": true,
9+
"verbatimModuleSyntax": true
10+
},
11+
"include": ["dist"]
12+
}

test/dts-fixture/tsconfig.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"strict": true,
7+
"declaration": true,
8+
"declarationMap": true,
9+
"outDir": "dist",
10+
"sourceMap": true,
11+
"verbatimModuleSyntax": true
12+
},
13+
"include": ["src"]
14+
}

0 commit comments

Comments
 (0)