Repository navigation
Expand file tree
/
Copy pathtsconfig.test.json
More file actions
76 lines (76 loc) · 3.76 KB
/
Copy pathtsconfig.test.json
File metadata and controls
76 lines (76 loc) · 3.76 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Typecheck config for test code: the `test/` eval harness and e2e suites, plus
// every colocated `*.test.ts(x)` under `src/`.
//
// The root `tsconfig.json` is `include: ["src/**/*"]`, so until this existed
// NOTHING under `test/` was typechecked by `pnpm typecheck` or by CI. That is the
// entire LongMemEval / recall / extraction / consolidation harness: the code every
// measurement in the memory epics is derived from, with no type gate.
//
// It was not theoretical. Widening the exported union `ConsolidationFallbackReason`
// in #803 left `Record<ConsolidationFallbackReason, number>` in
// `createConsolidationFallbackTracker` missing a key — a compile error that `tsc`
// reported nothing about because the file is under `test/`. Only a review bot
// caught it.
//
// Why a separate config rather than widening the root `include`: the root builds
// to CommonJS (`module: "commonjs"`, emitting `dist/`), and `test/` is ESM — it
// uses `import.meta.url` (see `test/memory/src/vault/embeddingCache.ts`), which TS
// rejects under a CommonJS target. So the two trees genuinely need different
// module settings, and `rootDir: "./src"` on the root config cannot cover `test/`
// either.
//
// `moduleResolution: "bundler"` matches how this code actually runs: vitest
// transforms it with esbuild, which resolves extensionless relative imports. Using
// `nodenext` instead would demand explicit `.js` extensions and fail on files that
// run fine today — checking them under rules they are never executed under would
// report problems that do not exist.
//
// The `src/**/*.test.*` globs are here for the same reason `test/**/*` is, and they
// arrived later because the hole was less obvious: the root config's
// `exclude: ["**/*.test.ts", ...]` silently dropped 168 colocated suites, so a test
// whose fixture had drifted out of shape still ran green and still reported nothing.
// That is worse than an uncompiled harness — a suite that passes `{}` where the
// signature grew three required fields keeps its name and stops testing what the
// name claims.
//
// They belong to THIS config, not a widened root `include`, and the reason is the
// same "never executed under those rules" argument as above, with receipts. The root
// targets `es2020`, so `expect(calls.at(-1))` — a normal idiom in these suites, and
// fine on every Node the tests run on — reports TS2550 "Property 'at' does not
// exist". And `rootDir: "./src"` rejects `src/lib/memory/entitySalience.test.ts`
// outright with TS6059, because it imports the shared topic dataset out of
// `test/memory/`. Checking src tests under the root config invents 5 errors in 4
// files that do not exist under the settings vitest actually uses.
{
"extends": "./tsconfig.json",
"compilerOptions": {
// Check only — `dist/` is built from `src/` by the root config.
"noEmit": true,
// Widen from the root's "./src" so test/ is in scope.
"rootDir": ".",
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2022",
"types": ["node"]
},
// Non-test `src/` arrives transitively via the imports and is checked as a side
// effect, which is intended: a `src` change that breaks a call site should fail
// here. The `*.spec.*` globs match nothing today but mirror
// `vitest.config.mts`'s include — vitest would run such a file, so tsc should see
// it the day someone adds one.
"include": [
"test/**/*",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
// The root config excludes `**/*.test.ts`; test files are the point here.
"exclude": [
// #832 (query decomposition out of recall)
"src/lib/memory/recall.test.ts",
"src/lib/memory/recallTool.test.ts",
// #834 (tool-save via retain)
"src/lib/memoryVault/tool.test.ts"
]
}