mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
A block-bodied callback whose enclosing call has a contextual array type infers a tuple union rather than an array union: `return pair ? [pair] : []` in a `f(): T[]` infers `[] | [pair]`. The flatten plan classified only array arms, so such a callback refused. The empty-arm detection now recognizes the empty tuple (a bare `[]` arm under a contextual array type), and the plan gains a `tuple` arm for a one-field-or-more tuple whose fields all contribute: each field is appended in order, exactly as an array arm's elements are. `checker. isArrayType` is false for tuples, so the arm scan accepts `isTupleType` too. Corpus 8525 pins the tuple arm, a two-field tuple arm, and an array arm beside a scalar arm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>