-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtsconfig.tests.json
More file actions
52 lines (52 loc) · 2.98 KB
/
Copy pathtsconfig.tests.json
File metadata and controls
52 lines (52 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
// CLI type-check gate for the test suites (tests/ + src/**/*.spec.ts).
//
// Neither the build (`nest build` → tsconfig.build.json, include ["src/**/*"],
// excludes `tests` and `**/*.spec.ts`) nor the linter type-checks the tests,
// and vitest runs through unplugin-swc, which transpiles without
// type-checking. So type errors in specs (wrong TestHelper arity, missing
// imports, stale API shapes) land unnoticed. `pnpm run typecheck:tests`
// (wired into `check` and CI) runs tsc over this config to close that gap.
//
// Extends the base tsconfig — path aliases, decorators, es2022 target,
// vitest/globals + node — so specs resolve exactly as they do under vitest.
// Adds only the test file scope, skipLibCheck, and noEmit; it is a pure gate.
//
// The include covers every spec the two vitest configs run (src/**/*.spec.ts,
// tests/unit/**, tests/**/*.e2e-spec.ts, tests/stories/**) AND the type
// assertion tests under tests/types/** — so it supersedes the narrow
// `test:types` (tests/types/tsconfig.json), which stays as a fast focused
// alias for iterating on just those files.
//
// `lib` is raised to ES2023 HERE and deliberately NOT in the base tsconfig.
//
// `pnpm run check` runs `oxlint --fix` BEFORE `typecheck:tests`, and the
// `unicorn/no-array-reverse` rule rewrites `.reverse()` into `.toReversed()`.
// Under the base lib (es2022, inherited from `target`) that method does not
// exist, so the linter could turn a green run RED in a file nobody edited —
// the toolchain sabotaging itself. `engines.node` is `>= 22` and `toReversed`
// has existed since Node 20, so the runtime was never the constraint; only the
// declared lib was.
//
// WHY NOT IN THE BASE tsconfig: `src/` is this framework's delivery. Vendor-mode
// consumers copy `src/core/**` into their own tree and compile it with THEIR
// tsconfig — the starter's, which targets es2022 with no `lib` (the CLI's
// vendor conversion widens `exclude` and `types`, never `lib`). Raising it here
// would let framework source adopt an ES2023 API that then fails to compile
// downstream. Tests and `scripts/**/*.ts` ship to nobody, so they are free to.
//
// The other half of the fix lives in `.oxlintrc.json`, which turns
// `unicorn/no-array-reverse` off for `src/**` so the linter cannot introduce
// into shipped source an API that shipped source may not use.
"extends": "./tsconfig.json",
"compilerOptions": {
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"noEmit": true,
"skipLibCheck": true
},
// `scripts/**/*.ts` is in scope for the same reason the specs are: it is TypeScript that the
// build never compiles (tsconfig.build.json is `src/**/*` only), so nothing else would catch a
// type error there. That matters most for scripts that stand in for automated coverage —
// `brevo-smoke.ts` is the manual verification for a MAJOR SDK upgrade, so it must not rot.
"include": ["scripts/**/*.ts", "src/**/*.spec.ts", "tests/**/*.ts"]
}