mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-04 08:04:37 +08:00
`["one"] | string[]` flowing into a `string[]` slot compiled to the checked extraction against the array arm alone, so a tuple value threw at runtime. Node accepts it: the value is an array, and nothing about a `string[]` position distinguishes which arm produced it. Let the union-width plan cover a mixed union that holds the destination arm beside a convertible one, and place that plan before the checked-extraction rule, so each arm converts on its tag (a tuple rebuilds, an array copies). A union whose only non-unit arm is the destination (`T[] | undefined`) still has nothing to convert and keeps its tested extraction. tests/corpus/8513-tuple-union-array.ts pins the binding, call-argument, readonly, and single-tuple shapes against Node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>