mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
`JSON.parse(text) as T` parses straight into the native layout only when every record member is a number, boolean, string, record or array, so one optional or nullable member sent the whole document through the dynamic tree and the checked cast. Record members typed as unions of those kinds with null and undefined now parse directly too, provided each JSON value kind selects at most one arm (at most one record and one array arm, no discriminant), so the checked route's first full match is that arm. Each union describes its slot representation: the nullable reference payload, the inline scalar tag and bits, or a tagged box built through a compiler-emitted box function. A missing undefined-armed member takes its ABSENT state, exactly as the checked route's missing key does; any other missing member, a value without a matching arm, or a duplicate key still declines to the checked route. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>