Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/runner/src/types/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ interface ExtendedAPI<ExtraContext> {
runIf: (condition: any) => ChainableTestAPI<ExtraContext>
}

export type CustomAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> &
export type TestAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> &
ExtendedAPI<ExtraContext> & {
extend: <T extends Record<string, any> = object>(
fixtures: Fixtures<T, ExtraContext>
) => CustomAPI<{
) => TestAPI<{
[K in keyof T | keyof ExtraContext]: K extends keyof T
? T[K]
: K extends keyof ExtraContext
Expand All @@ -424,7 +424,7 @@ export type CustomAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> &
}>
}

export type TestAPI<ExtraContext = object> = CustomAPI<ExtraContext>
export type { TestAPI as CustomAPI }

export interface FixtureOptions {
/**
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/dts-fixture/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@vitest/test-dts-fixture",
"private": true,
"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.json",
"check": "tsc -p tsconfig.check.json",
"test": "pnpm build && pnpm check"
},
"devDependencies": {
"vitest": "workspace:*"
}
}
7 changes: 7 additions & 0 deletions test/dts-fixture/src/repro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test } from 'vitest'

export const myTest = test.extend<{ now: number }>({
now: async ({}, use) => {
await use(Date.now())
},
})
16 changes: 16 additions & 0 deletions test/dts-fixture/tsconfig.check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ESNext",
// TODO: type check fails with NodeNext. probably we should fix this.
// ../../packages/vitest/index.d.cts:1:15 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./dist/index.js")' call instead.
// 1 export * from './dist/index.js'
// ~~~~~~~~~~~~~~~~~
"module": "ESNext",
"moduleResolution": "Bundler",
"types": [],
"strict": true,
"noEmit": true,
"verbatimModuleSyntax": true
},
"include": ["dist"]
}
14 changes: 14 additions & 0 deletions test/dts-fixture/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"sourceMap": true,
"verbatimModuleSyntax": true
},
"include": ["src"]
}