Skip to content

Commit 8cd8272

Browse files
authored
fix(vitest): improve defineProject and defineWorkspace types (#6198)
1 parent 17a81f0 commit 8cd8272

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/guide/workspace.md

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Workspace projects don't support all configuration properties. For better type s
9696

9797
:::code-group
9898
```ts [packages/a/vitest.config.ts] twoslash
99+
// @errors: 2769
99100
import { defineProject } from 'vitest/config'
100101

101102
export default defineProject({

netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build]
22
publish = "docs/.vitepress/dist"
33
command = "pnpm ci:docs"
4-
ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- docs/ package.json pnpm-lock.yaml"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF docs/ package.json pnpm-lock.yaml"
55

66
[build.environment]
77
NODE_VERSION = "20"

packages/vitest/src/config.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,22 @@ export function defineConfig(config: UserConfigExport): UserConfigExport {
4848
return config
4949
}
5050

51-
export function defineProject<T extends UserProjectConfigExport>(config: T): T {
51+
export function defineProject(config: UserWorkspaceConfig): UserWorkspaceConfig
52+
export function defineProject(config: Promise<UserWorkspaceConfig>): Promise<UserWorkspaceConfig>
53+
export function defineProject(config: UserProjectConfigFn): UserProjectConfigFn
54+
export function defineProject(config: UserProjectConfigExport): UserProjectConfigExport
55+
export function defineProject(config: UserProjectConfigExport): UserProjectConfigExport {
5256
return config
5357
}
5458

55-
type Workspace = string | (UserProjectConfigExport & { extends?: string })
59+
type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
60+
/**
61+
* Relative path to the extendable config. All other options will be merged with this config.
62+
* @example '../vite.config.ts'
63+
*/
64+
extends?: string
65+
})
5666

57-
export function defineWorkspace(config: Workspace[]): Workspace[] {
67+
export function defineWorkspace(config: WorkspaceProjectConfiguration[]): WorkspaceProjectConfiguration[] {
5868
return config
5969
}

0 commit comments

Comments
 (0)