Skip to content

ObjectDictionary closed by Object.preventExtensions/seal/freeze; values/entries/fromEntries helpers; Reflect of a dictionary - #119

Merged
ASDAlexander77 merged 1 commit into
mainfrom
object-reflect-dictionary
Nov 26, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
object-reflect-dictionary

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Library side of ASDAlexander77/TypeScriptCompiler#1037: a dictionary ({ [key: string]: T }) is the one object that gains and loses keys, and Object and Reflect now say so.

Changes

  • ObjectDictionary gets close(level) and closed() (the compiler calls them for Object.preventExtensions / seal / freeze and isExtensible / isSealed / isFrozen). A write it no longer takes throws a TypeError, as in JavaScript's strict mode.
  • objectDictionaryValues, objectDictionaryEntries, objectDictionaryFromEntries for Object.values / entries / fromEntries of a dictionary (free functions, as objectDictionaryAssign, so -mm=own fails only where one is used).
  • Reflect:
    • deleteProperty removes a dictionary's key (false when it is sealed or frozen). Any other object is sealed, so it is false for 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.ts drops that assertion. It now needs the run-time keys of any, so it is not under -mm=own, like get/set.
    • isExtensible / preventExtensions go by the target's own type: a dictionary until closed; an array is extensible and can't be closed (preventExtensions of one is false).
  • README: ObjectDictionary and the Object functions; Reflect updated.

Tests

  • New: object_dictionary_builtins.ts (all models), reflect_dictionary.ts (not own).
  • Local, Windows release, against a compiler built from #1037: gc and rc all passed; own all passed but bindings.ts, which fails the same way on the current compiler (destructuring a Set under own).

Landing

Needs a compiler release with ASDAlexander77/TypeScriptCompiler#1037: on today's release Object.isExtensible in Reflect is "'Object' is a type here", and CI downloads the newest release.

🤖 Generated with Claude Code

…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>
@ASDAlexander77
ASDAlexander77 merged commit 0266af4 into main Nov 26, 2026
1 of 9 checks passed
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