Skip to content

Answer undefined for missing Record and index-signature keys - #1236

Merged
ctate merged 5 commits into
mainfrom
ctate/answer-undefined-missing-317490
Oct 18, 2026
Merged

ctate merged 5 commits into
mainfrom
ctate/answer-undefined-missing-317490

Conversation

@ctate

@ctate ctate commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator
  • Keyed and dot reads of an index signature that miss now answer undefined, as in Node, instead of aborting; TypeScript's static types are unchanged.
  • Numeric reads whose consumers treat undefined like NaN stay plain doubles, so the hit path costs the same as before (bench:runtime geomean -0.3%, no workload slower; tsc-ts kit at parity).
  • Nested reads and writes through a missing entry throw Node's TypeError messages.

Fixes #964

A keyed or dot read of an index signature that misses now answers
undefined, as in Node, instead of aborting with "record has no key".
The read carries an explicit optional value through the same analysis
that already widens bindings, parameters, returns and fields for missing
array elements; TypeScript's static types are unchanged. Numeric reads
whose consumers treat undefined like NaN lower to plain doubles, and
nested reads and writes through a missing entry throw Node's TypeError.

Fixes #964
Co-authored-by: Quim T. <[email protected]>
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 18, 2026 3:37pm UTC

The shard balance test needs measured costs for the new corpus programs
5952-5954 (plain and sanitized), timed locally and scaled to the CI
runners' existing entries.

Fixes #964
Co-authored-by: Quim T. <[email protected]>
Comment thread tests/harness/corpus-costs.json Resolved
@ctate
ctate merged commit 307387c into main Oct 18, 2026
66 checks passed
@ctate
ctate deleted the ctate/answer-undefined-missing-317490 branch October 18, 2026 15:58

This branch was successfully deployed

1 active deployment
Preview — 835ee0a0 Deployed Oct 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Top-level object literal with a computed key traps with "record has no key" at startup

1 participant