You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(tooling): make an unparseable source REFUSE instead of scoring clean (#10573)
`ts.createSourceFile` never throws. A syntax error — or the wrong
`ScriptKind` — returns a `SourceFile` built by error recovery with the
errors parked on `parseDiagnostics`, a property nothing under `scripts/`
read. Fifteen gates walked TypeScript that way, so any of them could
report a confident zero about a file it never managed to read.
This was not latent. `check-engine-double-contract.mjs` forced
`ts.ScriptKind.TSX` on all 2504 `*.{test,spec}.{ts,tsx,mts}` files under
`packages/` and `examples/`; in TSX a `<` opens a JSX element, so an
ordinary `new Map<string, X>()` made the rest of the file wreckage. 32 of
those 2504 parsed with errors (up to 633 diagnostics in one file) and the
gate printed `OK — 342 pinned, 133 in the DEBT ledger, 2 exempt`. Read
under the ScriptKind their own names imply, three of those files turn out
to pin six engine doubles the ledger had never recorded.
- `scripts/ts-parse.mjs` — the one sanctioned parse. Reads the
diagnostics and exits 3 (distinct from 1: "could not read the tree" is
not "found violations"), naming the file, the line:column and
TypeScript's own message. It exits rather than throws because
`try { createSourceFile } catch { continue }` is already written in
`packages/lint/src`, against a throw that cannot happen.
- `scripts/check-parse-guard.mjs` — the half that makes it hold. A raw
`ts.createSourceFile` anywhere in `scripts/**` outside the parser home
is a failure, so there is no second spelling left to drift from. Same
shape as `invoked-as.mjs` + `check-entry-guard.mjs`, and for the same
measured reason.
- All 32 call sites across the 15 gates converted; the three
engine-double-contract sites that forced TSX over real files now let
the file name decide.
- `engine-double-contract.pinned.json` grows by the 6 rows that became
visible: 342 -> 348 pinned, 0 lost.
Fixes: #10133
Claude-Session: https://claude.ai/code/session_01DdCnBGcHeufjrq7drTD3wt
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments