mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
`.filter` on `A[] | B[]` refused with SC2020: `lowerArrayUnionHofCall` admitted only `map` and `forEach`. Under TS 5.2's callable-union rule the predicate runs over `A | B`, and the result element is the one the predicate names — `(b): b is TextContent` over a union of block arrays answers `TextContent[]` — which no single arm's element need equal. `filter` joins the same arm dispatch: each arm filters its own concrete array through the existing per-arm helper, and its survivors then pass through the checked conversion to the checker's result element, so a predicate that kept an element it does not describe throws instead of reinterpreting a value. An arm with no such conversion (a boolean predicate that names no narrower element) leaves the SC2020 fence in place. Typed programs are untouched: the gate only widens, and `map`/`forEach` keep their exact helper key, so the helpers a program already emitted stay byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>