Repository navigation
Convert object literals with accessors to unknown again - #1506
Merged
Merged
Conversation
#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.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
unknownis expected compiles again (node24-file-url-options.tsreads its options'windowsgetter); Refuse JSON and dynamic copies of object literals with accessors #1490 had refused it.JSON.stringifyof such typed values stays refused.