From 6bbd04e0bfa6576f8e433efeca2ba32222f635f4 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 23 Jul 2026 23:43:46 +0530 Subject: [PATCH] test: type-check tests and docs - split __tests__/tsconfig.json into per-suite projects so unit tests check against src (via path aliases) while e2e/init check against the built package, avoiding mixing both type universes in one program - explicitly include the .vitepress dir in the e2e project - dotted directories are skipped by default, so it was never type-checked - add a `*.vue` shim for the e2e custom theme (named env.d.ts because a shims.d.ts would be dropped in favor of the adjacent shims.ts) - add a tsconfig for docs, checked with vue-tsc - wire everything into `pnpm test` as `test:types` Co-Authored-By: Claude Fable 5 --- __tests__/e2e/env.d.ts | 5 +++++ __tests__/e2e/tsconfig.json | 4 ++++ __tests__/init/tsconfig.json | 3 +++ __tests__/tsconfig.json | 8 ++------ __tests__/unit/tsconfig.json | 18 ++++++++++++++++++ docs/tsconfig.json | 8 ++++++++ package.json | 3 ++- 7 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 __tests__/e2e/env.d.ts create mode 100644 __tests__/e2e/tsconfig.json create mode 100644 __tests__/init/tsconfig.json create mode 100644 __tests__/unit/tsconfig.json create mode 100644 docs/tsconfig.json diff --git a/__tests__/e2e/env.d.ts b/__tests__/e2e/env.d.ts new file mode 100644 index 000000000..a99cf76cc --- /dev/null +++ b/__tests__/e2e/env.d.ts @@ -0,0 +1,5 @@ +declare module '*.vue' { + import type { DefineComponent } from 'vue' + const component: DefineComponent + export default component +} diff --git a/__tests__/e2e/tsconfig.json b/__tests__/e2e/tsconfig.json new file mode 100644 index 000000000..44878152c --- /dev/null +++ b/__tests__/e2e/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["**/*", ".vitepress/**/*"] +} diff --git a/__tests__/init/tsconfig.json b/__tests__/init/tsconfig.json new file mode 100644 index 000000000..3c43903cf --- /dev/null +++ b/__tests__/init/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../tsconfig.json" +} diff --git a/__tests__/tsconfig.json b/__tests__/tsconfig.json index 9cce3a1ef..366c4ab87 100644 --- a/__tests__/tsconfig.json +++ b/__tests__/tsconfig.json @@ -1,12 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { + "noEmit": true, "isolatedModules": false, - "types": ["node", "vitest/globals"], - "paths": { - "client/*": ["../src/client/*"], - "node/*": ["../src/node/*"], - "shared/*": ["../src/shared/*"] - } + "types": ["node", "vitest/globals"] } } diff --git a/__tests__/unit/tsconfig.json b/__tests__/unit/tsconfig.json new file mode 100644 index 000000000..f7ff23294 --- /dev/null +++ b/__tests__/unit/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "types": [ + "node", + "vitest/globals", + "vite/client", + "../../src/client/shims.d.ts" + ], + "paths": { + "client/*": ["../../src/client/*"], + "node/*": ["../../src/node/*"], + "shared/*": ["../../src/shared/*"], + "vitepress": ["../../src/client/index.ts"], + "vitepress/theme": ["../../theme.d.ts"] + } + } +} diff --git a/docs/tsconfig.json b/docs/tsconfig.json new file mode 100644 index 000000000..c36178307 --- /dev/null +++ b/docs/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "noEmit": true, + "types": ["node"] + }, + "include": ["**/*", ".vitepress/**/*"] +} diff --git a/package.json b/package.json index 53245c465..44fd3a7f7 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,8 @@ "build:prepare": "pnpm clean && node scripts/copyShared.ts", "build:client": "vue-tsc --noEmit -p src/client && tsc -p src/client && node scripts/copyClient.ts", "build:node": "tsc -p src/node --noEmit && rollup --config rollup.config.ts --configPlugin esbuild", - "test": "pnpm --aggregate-output --reporter=append-only '/^test:(unit|e2e|init)$/'", + "test": "pnpm --aggregate-output --reporter=append-only '/^test:(types|unit|e2e|init)$/'", + "test:types": "tsc -p __tests__/unit && tsc -p __tests__/e2e && tsc -p __tests__/init && vue-tsc -p docs", "test:unit": "vitest run -r __tests__/unit", "test:unit:watch": "vitest -r __tests__/unit", "test:e2e": "pnpm test:e2e-dev && pnpm test:e2e-build",