mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-05 08:13:06 +08:00
In Node, `decoder.decode(undefined)` returns "" like `decode()`, and flushes bytes pending from streamed input. scriptc refused a statically undefined argument and an argument typed `Uint8Array | undefined` with SC2020, and `decode(x!)` on an undefined value threw a TypeError. The decode input lowering now evaluates a statically undefined argument for its effects and decodes an empty Uint8Array, and reads the undefined arm of `Uint8Array | undefined` as an empty Uint8Array, in both the decoder-value and the `new TextDecoder(label).decode(...)` paths. A non-null assertion passed to decode keeps the undefined it removes, instead of the checked narrowing other optional standard library parameters keep. Inputs that may be null are refused as before (`decode(null)` throws a TypeError in Node).