mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
TypeScript types `read ?? "text"` as number when the read is typed number, and `() => xs[i]` as returning number. Declared functions already widened their returns for both (the primitive result union and the optional read), but arrow functions and function expressions kept the checker's return, so the closure narrowed its result and threw "a 'string' value is not representable" or "undefined is not representable" (the scanbox `[string, () => unknown][]` probe table). Unannotated TypeScript lambdas now get the same widened return as declared functions. A const or global binding of such a lambda keeps the checker's parameters and takes the widened result, and calls through the binding count as optional or primitive-union results for the enclosing function's return.