mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-09 14:53:16 +08:00
`s.match(re) || []` contextually types the empty array by the tuple-like RegExpMatchArray, so typescript-go builds an empty tuple target and clones it as an array literal. The clone keeps ObjectFlagsTuple on TypeReference data, and the API's newTypeResponse panics (interface conversion to *TupleType) whenever it serializes the clone, for example as a member of `RegExpMatchArray | []`. Whole-program analyses asked for such union members first, so every program containing the pattern (moment.js, or a two-line TypeScript file) failed at 1:1 with SC0004. A union whose members typescript-go panics to serialize is now unmappable at the top of mapType, the any-array probe answers false for it, and the panic is remembered per type instead of re-requested. Queries that still need the members keep the source-anchored SC0004 on their own statement (a runtime fence in JavaScript). Other checker panics are unchanged. The panic itself is an upstream bug in internal/api/proto.go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>