--lib is documented as Extra ambient declaration file (repeatable), but only the last occurrence is honoured. Passing a second one silently discards the first, so an app that splits its ambient declarations across files gets the diagnostics of whichever file it happened to list last.
Measured on 0.2.176, same project and same glob every time, counting error TS lines:
| invocation | errors |
|---|---|
(no --lib) | 59 |
--lib A | 28 |
--lib B | 59 |
--lib A --lib B | 59 ← same as B alone |
--lib B --lib A | 28 ← same as A alone |
A is types/app.d.ts (the app's domain globals — AuthUser, ProjectRow, MeUser, …), B is types/stx-runtime.d.ts. The last two rows are the whole report: order decides the result, and the flag that is meant to accumulate replaces instead.
Why this is easy to lose an afternoon to
The failure is silent and it points the wrong way. Listing every declaration file — the obvious thing to do, and what "repeatable" invites — lands on the unhelped baseline of 59, which reads as "the flag does nothing" rather than "the flag is dropping all but one of your files". I concluded --lib was broken outright and only found the real rule by bisecting one file at a time.
It also masks real errors rather than merely hiding types. With the app's globals loaded, 15 TS2304 Cannot find name collapse into 12 genuine, actionable errors that were previously reported as missing names — including a null-dereference in a SQL-interpolating path. Getting the invocation wrong does not just under-report; it reports the wrong kind of problem.
Suggested fix
Collect the values instead of overwriting — accumulate --lib into an array and pass all of them to the program's root file set. If accepting only one is deliberate, the help text should say (last wins) rather than (repeatable), and passing more than one should warn.
Note on adjacent history
stx#1906 (--lib silently suppresses every diagnostic, closed) covered a different symptom of the same flag — that one reported 0 errors, this one reports the baseline. Also fixed since I last measured: a relative --lib path used to be ignored silently and now works, so --lib types/app.d.ts and --lib "$PWD/types/app.d.ts" both give 28. This is the residual.
Environment
- stx 0.2.176 (built from source), bun 1.3.14, macOS 15
- 38-view Stacks app used as the e2e surface for stx