--help calls --lib repeatable:
--lib <path> Extra ambient declaration file (repeatable)It is not. The last one wins and the earlier ones are dropped silently, so a project that splits its ambient declarations across two files gets one of them and no indication the other was ignored.
Repro
Two ambient files. types/domain.d.ts declares the app's domain types (declare type IssueLevel = …), types/globals.d.ts declares one SSR global (declare const requestContext: …). Measured on stx 0.2.176, .stx/cache cleared before each run, counting unresolved-name errors across the same 38 files:
| invocation | requestContext unresolved | IssueLevel unresolved | total |
|---|---|---|---|
--lib types/domain.d.ts | 78 | 0 | 407 |
--lib types/globals.d.ts | 0 | 11 | 323 |
--lib types/domain.d.ts --lib types/globals.d.ts | 0 | 11 | 323 |
The third row is identical to the second. Passing both is exactly equivalent to passing only the last, and the 11 IssueLevel errors are the proof that the first file was discarded.
Concatenating the two into one file resolves everything both declared, which is the workaround — but it forces unrelated declarations to share a file purely to satisfy the flag.
Why it is easy to miss
The failure is silent and looks like a project problem. Adding a second --lib to fix one set of unresolved names appears to work, because the names you were chasing resolve; the names the first file was providing quietly break at the same moment, and if you were not counting per-name you would read the new total as progress. The total here went 407 → 323 while a category of error was being introduced.
Adjacent, possibly the same root cause
The checker does not appear to read ambient declarations from the project's tsconfig.json at all. This repo has "include": ["types/**/*.d.ts", …] and tsc --noEmit resolves every one of these names, but a typecheck run with no --lib reports all 407 including the ones types/domain.d.ts declares. If the checker built its program from tsconfig, --lib would rarely be needed and this bug would be much harder to hit.