|
| 1 | +// The TEST-layer type-check program (#14917), adopting the mechanism #5286 set |
| 2 | +// for `packages/spec` and #5449 generalised — the route `packages/objectql` |
| 3 | +// (#13676), `packages/runtime` (#14504) and `packages/core` (#14613) already |
| 4 | +// run. `tsconfig.json` beside this file stays exactly as it is: it is the BUILD |
| 5 | +// config, and its `**/*.test.ts` exclusion has a reason. This sibling puts the |
| 6 | +// excluded layer back in front of tsc, and `package.json`'s `typecheck` script |
| 7 | +// NAMES it (via `check:test-typecheck --project`), because a config no script |
| 8 | +// invokes is exactly the phantom this whole mechanism is about. |
| 9 | +// |
| 10 | +// BEFORE THIS FILE, NO tsc PROGRAM COMPILED A SINGLE TEST FILE HERE, and that |
| 11 | +// is measured rather than read off the config. At 6ed4b811af with the |
| 12 | +// dependency closure built first, `tsc --noEmit --listFiles -p tsconfig.json` |
| 13 | +// puts **0** of this package's 30 `src/**/*.test.ts` files in the program — |
| 14 | +// while all **10** of its non-test `src/**` files ARE there, so the zero is the |
| 15 | +// `exclude` line and not a probe that sees nothing. Under this file the count is |
| 16 | +// **30 of 30**, with the same 10 non-test files beside them. |
| 17 | +// `pnpm --filter @objectstack/driver-mongodb typecheck` exiting 0 was a true |
| 18 | +// sentence carrying no information about any test file in this package. |
| 19 | +// |
| 20 | +// ⚠️ WHAT THE CARD SAID, AND WHAT WAS ACTUALLY WRONG. The filing's headline — |
| 21 | +// that a compile-time `Equals` / `IsAny` pin here is "checked by nothing" — is |
| 22 | +// FALSE, and the correction on the card is right: a second program does compile |
| 23 | +// these files. `scripts/check-type-check-coverage.mjs`'s `remeasureProject` |
| 24 | +// extends this package's tsconfig, drops only the test glob, and compares the |
| 25 | +// result against its `TEST_DEBT` ledger. That is how CI caught PR #14914's |
| 26 | +// three TS18047 errors, which this package's own `typecheck` could not see. So |
| 27 | +// the pins were not phantoms. What was true is narrower and is what this file |
| 28 | +// closes: the only program reading this layer was a DEBT RATCHET — an |
| 29 | +// instrument that reports a NUMBER and fails when the number MOVES, not a gate |
| 30 | +// that reports a pass. |
| 31 | +// |
| 32 | +// What differs from the build config, and what deliberately does NOT: |
| 33 | +// - module semantics ONLY, plus `lib`. The tests are written and executed as |
| 34 | +// ESM by vitest (esbuild/vite), while this package has no `"type": |
| 35 | +// "module"`, so the build config's NodeNext compiles them as CJS. Measured |
| 36 | +// cost of that mismatch here: ALL 10 of the raw diagnostics — TS1309 x7 |
| 37 | +// ("cannot use `await` at the top level" in a CJS program, one per suite |
| 38 | +// that awaits `startMongod()` at module scope) and TS2550 x3 (all three the |
| 39 | +// same `Array.prototype.at` message in `mongodb-findone-options.test.ts`, |
| 40 | +// against a `lib` older than es2022). Those 10 are about the CHECK, never |
| 41 | +// about the code. Matching vitest is fidelity, not laxity. No `DOM` in |
| 42 | +// `lib`: nothing in this layer touches a browser global. |
| 43 | +// - ⛔ STRICTNESS IS UNTOUCHED. `strict`, `noUnusedLocals`, |
| 44 | +// `noUnusedParameters`, `noImplicitReturns`, `noFallthroughCasesInSwitch` |
| 45 | +// are inherited from the root config, and `types: ["node"]` restates |
| 46 | +// `tsconfig.json`'s — load-bearing for the same reason its comment gives, |
| 47 | +// since the `.test.ts` files call the `setTimeout` / `console` users in |
| 48 | +// `src/test-mongod.ts` and use those globals themselves. Nothing here may |
| 49 | +// loosen a type rule; if a test does not compile, that is the finding. |
| 50 | +// ⛔ Not one `any` and not one `@ts-expect-error` was added to any test file |
| 51 | +// to open this gate — that shape is what turns a real gate into a phantom. |
| 52 | +// - ⚠️ `noUnusedLocals` / `noUnusedParameters` are worth naming explicitly: |
| 53 | +// they are `true` at the root and `false` in `driver-turso`'s own overrides |
| 54 | +// but NOT in this package's, so this layer meets STRICTER settings than the |
| 55 | +// sibling driver whose clean state might otherwise be read as a prediction. |
| 56 | +// Measured: neither fires here, in either direction. Zero of the 10. |
| 57 | +// - `rootDir` is INHERITED as `./src` and deliberately not widened. Like |
| 58 | +// `packages/runtime` and unlike `objectql` / `spec`, this layer produces no |
| 59 | +// TS6059: measured, every file this program admits is already under `src` |
| 60 | +// (all 30 test files sit beside the sources they exercise). Widening it "to |
| 61 | +// be safe" would admit files the build config does not and change what the |
| 62 | +// gate judges, so it stays as the build config has it. |
| 63 | +// |
| 64 | +// ⭐ MEASURED at 6ed4b811af, dependency closure built first (an error count |
| 65 | +// taken against an unbuilt closure is not a reading — unresolved-import |
| 66 | +// cascades inflate it): this program reports **0 errors across 30 files**, from |
| 67 | +// a raw 10 under the inherited NodeNext semantics. Every one of the 10 was |
| 68 | +// config-tier and none survives; the residue is EMPTY. So unlike `objectql`, |
| 69 | +// `runtime`, `spec` and `core`, this package needs **no** |
| 70 | +// `test-typecheck-debt.json` at all, and carries none — which is the strongest |
| 71 | +// form of this gate: all 30 files are unledgered, so any error any one of them |
| 72 | +// ever gains is red on arrival, starting today. |
| 73 | +// |
| 74 | +// That empty residue is also why the `TEST_DEBT` entry in |
| 75 | +// `scripts/check-type-check-coverage.mjs` GRADUATES in the same change rather |
| 76 | +// than being paid down. Its recorded 10 and its recorded composition |
| 77 | +// ("TS1309 x7, TS2550 x3") match this file's raw reading exactly, which is the |
| 78 | +// cleanest possible confirmation that the ledger was measuring the CHECK's |
| 79 | +// misconfiguration and never a defect in the tests. |
| 80 | +{ |
| 81 | + "extends": "./tsconfig.json", |
| 82 | + "compilerOptions": { |
| 83 | + "noEmit": true, |
| 84 | + "module": "esnext", |
| 85 | + "moduleResolution": "bundler", |
| 86 | + "lib": ["ES2022"], |
| 87 | + "types": ["node"] |
| 88 | + }, |
| 89 | + "include": ["src/**/*"], |
| 90 | + "exclude": ["node_modules", "dist"] |
| 91 | +} |
0 commit comments