Repository navigation
ObjectDictionary closed by Object.preventExtensions/seal/freeze; values/entries/fromEntries helpers; Reflect of a dictionary - #119
Merged
Conversation
…ectDictionaryValues/Entries/FromEntries; Reflect deleteProperty, isExtensible and preventExtensions of a dictionary - ObjectDictionary has `close(level)` and `closed()` (the compiler calls them); a write it no longer takes throws a TypeError, as JavaScript's strict mode does - objectDictionaryValues, objectDictionaryEntries, objectDictionaryFromEntries for Object.values/entries/fromEntries - Reflect: deleteProperty removes a dictionary's key (false when sealed); any other object is sealed, so false for a key it has (it threw "not available"); isExtensible/preventExtensions by the target's own type (an array is extensible and can't be closed) - tests object_dictionary_builtins.ts, reflect_dictionary.ts; README - needs a compiler with the Object functions of a dictionary (TypeScriptCompiler object-reflect-dictionary) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Library side of ASDAlexander77/TypeScriptCompiler#1037: a dictionary (
{ [key: string]: T }) is the one object that gains and loses keys, andObjectandReflectnow say so.Changes
ObjectDictionarygetsclose(level)andclosed()(the compiler calls them forObject.preventExtensions/seal/freezeandisExtensible/isSealed/isFrozen). A write it no longer takes throws aTypeError, as in JavaScript's strict mode.objectDictionaryValues,objectDictionaryEntries,objectDictionaryFromEntriesforObject.values/entries/fromEntriesof a dictionary (free functions, asobjectDictionaryAssign, so-mm=ownfails only where one is used).Reflect:deletePropertyremoves a dictionary's key (false when it is sealed or frozen). Any other object is sealed, so it isfalsefor a key it has - it threw "not available" before (Reflect: what can't be done throws "not available" rather than giving a made-up answer #111);reflect_not_available.tsdrops that assertion. It now needs the run-time keys ofany, so it is not under-mm=own, likeget/set.isExtensible/preventExtensionsgo by the target's own type: a dictionary until closed; an array is extensible and can't be closed (preventExtensionsof one isfalse).ObjectDictionaryand theObjectfunctions;Reflectupdated.Tests
object_dictionary_builtins.ts(all models),reflect_dictionary.ts(not own).bindings.ts, which fails the same way on the current compiler (destructuring aSetunder own).Landing
Needs a compiler release with ASDAlexander77/TypeScriptCompiler#1037: on today's release
Object.isExtensibleinReflectis "'Object' is a type here", and CI downloads the newest release.🤖 Generated with Claude Code