mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
An unannotated `const xs = []` (or `let`) inside a function, which TypeScript types by the elements written before each read, takes the array type its settled reads have: records pushed in a loop give a record array, numbers a number[], strings a string[]. Reads inside closures, which the checker leaves unsettled, do not count. When settled reads disagree or the binding is reassigned, the binding is a dynamic array, as the same binding already is at module scope. Before, such a binding was always number[] and pushes of other values were refused. Fixes #1623 Co-authored-by: ejc3 <1694850+ejc3@users.noreply.github.com>