mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
Two JavaScript object literal mappings from #1799 broke packages. A property initialized to `[]` has the checker type `never[]`, and never's element maps to f64. A literal with such a property builds as a checked-dynamic object when it lowers on its own. A literal nested in one that maps to a record (`{ common: { issues: [] }, path: params?.path || [] }`, zod 3's parse context) lowers against its record type, so the property was a `number[]`. `ctx.common.issues.push(issue)` then threw "TypeError: expected number at $, got object", where Node pushes the record. Such a property now maps to the checked-dynamic array, as a property initialized to `undefined` or `null` maps to the checked-dynamic value. That `undefined`/`null` rule also matched the properties the checker adds when it normalizes a union of literals: `{ _tag, value } | { _tag, error }` gains an optional `error?: undefined` and `value?: undefined`. Mapping those to the checked-dynamic value let `{ _tag, value }` fit both arms, and Effect 4's CLI parser (`consumeFlagValue`) failed with SC2003 "union conversion has no unambiguous layout mapping". The rule now skips optional properties, so they keep their unit-only type and each literal converts to its own arm.