From 162c19e1cb58b87b17455180564aef3f3c73719a Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Tue, 23 Jul 2024 09:31:02 +0200 Subject: [PATCH 1/2] fix(vitest): improve `defineProject` and defineWorkspace types --- packages/vitest/src/config.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/vitest/src/config.ts b/packages/vitest/src/config.ts index 6b80fd38df45..4662621393d8 100644 --- a/packages/vitest/src/config.ts +++ b/packages/vitest/src/config.ts @@ -48,12 +48,22 @@ export function defineConfig(config: UserConfigExport): UserConfigExport { return config } -export function defineProject(config: T): T { +export function defineProject(config: UserWorkspaceConfig): UserWorkspaceConfig +export function defineProject(config: Promise): Promise +export function defineProject(config: UserProjectConfigFn): UserProjectConfigFn +export function defineProject(config: UserProjectConfigExport): UserProjectConfigExport +export function defineProject(config: UserProjectConfigExport): UserProjectConfigExport { return config } -type Workspace = string | (UserProjectConfigExport & { extends?: string }) +type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & { + /** + * Relative path to the extendable config. All other options will be merged with this config. + * @example '../vite.config.ts' + */ + extends?: string +}) -export function defineWorkspace(config: Workspace[]): Workspace[] { +export function defineWorkspace(config: WorkspaceProjectConfiguration[]): WorkspaceProjectConfiguration[] { return config } From ffa19f05d730e74884c809d3be1274e62dfb5101 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Tue, 23 Jul 2024 09:38:37 +0200 Subject: [PATCH 2/2] chore: cleanup --- docs/guide/workspace.md | 1 + netlify.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/guide/workspace.md b/docs/guide/workspace.md index 70818b605ca1..920106df359b 100644 --- a/docs/guide/workspace.md +++ b/docs/guide/workspace.md @@ -96,6 +96,7 @@ Workspace projects don't support all configuration properties. For better type s :::code-group ```ts [packages/a/vitest.config.ts] twoslash +// @errors: 2769 import { defineProject } from 'vitest/config' export default defineProject({ diff --git a/netlify.toml b/netlify.toml index e7848797fbad..29eeea9bced9 100755 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,7 @@ [build] publish = "docs/.vitepress/dist" command = "pnpm ci:docs" -ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- docs/ package.json pnpm-lock.yaml" +ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF docs/ package.json pnpm-lock.yaml" [build.environment] NODE_VERSION = "20"