mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
In JavaScript, `counts.get(key) ?? 0` on a Map the compiler types as Map<string, number> is typed `any` by the checker, so `??` was lowered on checked-dynamic values: the `number | undefined` read converted to a dynamic value, which allocated a heap union for every read, and the test ran on that value. When the left of such a `??` is a union of one number, boolean or string arm with undefined or null, and the default has the same type, the test and the default now run on the typed path, where the read needs no heap union, and only the result converts to a dynamic value. Other defaults keep the dynamic path. New corpus program: untyped-nullish-scalar-defaults.mjs.