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 <noreply@anthropic.com>
pull/5335/head
Divyansh Singh 4 days ago
parent 572bc63bd8
commit 6bbd04e0bf

@ -0,0 +1,5 @@
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent
export default component
}

@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["**/*", ".vitepress/**/*"]
}

@ -0,0 +1,3 @@
{
"extends": "../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"]
}
}

@ -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"]
}
}
}

@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"types": ["node"]
},
"include": ["**/*", ".vitepress/**/*"]
}

@ -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",

Loading…
Cancel
Save