A feature was reported complete on the strength of a green unit-test run: 50 tests,
A feature was reported complete on the strength of a green unit-test run: 50 tests, exit 0. The project's real gate also runs a production build, and that build failed on a type error in a test fixture. The failure had been present the whole time and the passing suite had hidden it, because the test runner — vitest, and jest likewise — executes TypeScript by stripping types and never type checks.
The underlying defect was a third-party SDK whose .d.ts disagreed with its own runtime, in both directions at once:
new Lib.UnionType(0) // works at runtime, rejected by tsc ("Expected 0 arguments, but got 1")
Lib.UnionType[0]() // satisfies tsc, throws at runtime ("is not a function")The declaration file advertised a static member that does not exist at runtime, and omitted the constructor that does. So each of the two obvious spellings fails on the opposite side, and fixing one error reliably introduces the other. Two rounds were burned swapping between them.
Two independent mistakes that compound.
First, treating one gate as a proxy for another. "Tests pass" answers whether the code behaves correctly when run; it says nothing about whether it type checks, lints, or builds. A pipeline whose stages are chained with && compounds this: an earlier failing stage means the later stages never execute, so a red pipeline can leave a whole gate simply unmeasured rather than failed. That is invisible unless the gate is run on its own.
Second, treating a type declaration as evidence about runtime. A .d.ts is a claim maintained separately from the implementation, and for hand-written declarations of generated or union types the two drift. When they disagree, guessing a third spelling is a coin flip in a space where both known candidates already failed.
Read the gate's own exit status. Do not infer it from a neighbouring gate, and do not infer it from a chained pipeline that may have stopped before reaching it.
npx vitest run <path> # behaviour, when run — never type checks
npx tsc --noEmit # types
npm run build # what production actually doesA passing suite certifies runtime behaviour of executed code. Type errors in files the suite never type checks — including test fixtures — are outside what it can see. A green suite and a broken build are not contradictory; they are two different gates answering two different questions.
The swap between the two obvious spellings is a trap, not a search: it fixes one gate by breaking the other, and the round trip returns you to the original failure. Swapping the constructor call for the statically-declared member fixed tsc and broke all six test files; swapping back would have restored the original build failure.
Establish what the module actually exposes at runtime, and stop treating the .d.ts as evidence about it.
All three gates, run separately, each read from its own exit code:
npx vitest run <path> # → 6 files, 50 tests, exit 0
npx tsc --noEmit # → exit 0
npm run build # → exit 0The separate execution is the point, not a formality: the project's chained check script stopped at the test stage and never reached the build, so the build gate had no result at all until it was invoked directly. A gate you have not run yourself has no status — an absent result is not a passing result.
typescript-solution-tsconfig-silent-nocheck, which covers the case where the checker's configuration points at nothing (solution-style tsconfig with "files": [], so tsc typechecks an empty set). Here the checker was correctly pointed and correctly reported a real error — it simply was never run, and the error was real rather than an artifact of empty input. Adjacent in theme, different in mechanism and fix.