Skip to content

Convert object literals with accessors to unknown again - #1506

Merged
ctate merged 2 commits into
mainfrom
ctate/convert-object-literals-ad9284
Oct 20, 2026
Merged

ctate merged 2 commits into
mainfrom
ctate/convert-object-literals-ad9284

Conversation

@ctate

@ctate ctate commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

#1490 also took records with accessor slots out of the dyn-convertible
domain, which refused passing such a literal where `unknown` is
expected. Native APIs read these values through their accessor slots:
fileURLToPath, fileURLToPathBuffer and pathToFileURL call the `windows`
getter of an options object, so tests/corpus/node24-file-url-options.ts
stopped compiling.

Records with accessor slots convert to checked-dynamic values again.
JSON.stringify of their typed values stays refused, since the typed
serializer cannot invoke the getter.
@vercel

vercel Bot commented Oct 20, 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 20, 2026 8:56am UTC

Comment thread packages/compiler/src/ir/ir.ts
An object literal with get/set accessors converted to `any` or `unknown`
listed its reserved closure slots (`%get:x`) as data keys, so a dynamic
read of the accessor answered undefined without calling the getter, and
Object.keys and JSON.stringify listed the slot instead of the property.

The checked-dynamic copy now defines each accessor as one enumerable,
configurable property whose getter and setter are the slot closures, in
declaration order: the record shape records its accessor key order
(`accessorOrder`). Live views of such records build that copy, and
checking a copy back into the record reads the closures from the
accessor's getter and setter. Reads, writes, Object.keys,
Object.entries, JSON.stringify and property descriptors answer as in
Node.
@ctate
ctate merged commit f31f856 into main Oct 20, 2026
66 checks passed
@ctate
ctate deleted the ctate/convert-object-literals-ad9284 branch October 20, 2026 13:55

This branch was successfully deployed

1 active deployment
Preview — e1e45f12 Deployed Oct 20, 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.

1 participant