Repository navigation
Reflect: get, set, has, ownKeys, deleteProperty, isExtensible, preventExtensions, apply, construct - #110
Merged
Conversation
…tExtensions, apply, construct A namespace of generic functions in lib.generics, as Atomics is. The key operations read the target through `any`, so its keys are looked up at run time by the compiler (x[k], k in x, Object.keys of `any`): a class's public fields, accessors and methods of its actual class, an object literal's or a tuple's fields, an array's indices. No object can gain or lose a key: set of a key it has not, of a value its type does not take, or of an object literal (a copy as `any`) is false; isExtensible is false; deleteProperty is true only of a key not there. apply does not use thisArgument. No getPrototypeOf, setPrototypeOf, defineProperty or getOwnPropertyDescriptor. ownKeys of a class needs the compiler's Object.keys of `any` (TypeScriptCompiler#955). 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.
Reflectas a namespace of generic functions inlib.generics.ts, likeAtomics.Merge after ASDAlexander77/TypeScriptCompiler#955:
Reflect.ownKeysof a class usesObject.keysofany, which that PR adds.tests/reflect_keys.tsfails to compile until CI has a compiler with it.The key operations read the target through
any, so the compiler looks its keys up at run time (ASDAlexander77/TypeScriptCompiler#940, #942, #953, #955 there):get,hasgetgivesanyownKeysObject.keysgives: public fields, base class first; no accessors, methods or"length"setfalsefor a key the object has not, a value its type does not take, or an object literal (a copy asany);nullthrowsdeletePropertytrueonly of a key that is not thereisExtensible/preventExtensionsfalse/true: no object can gain a keyapply,constructthisArgumentnot usedNot here (no prototypes or descriptors):
getPrototypeOf,setPrototypeOf,defineProperty,getOwnPropertyDescriptor.Under
-mm=ownthe key operations are compile errors (anyhas no keys), andconstructcan't give a constructor a string or object from the lent arguments array;apply,isExtensibleandpreventExtensionswork.Tests:
reflect_keys.ts(not own),reflect_apply.ts(every model),reflect_construct_kept.ts(not own).Verified locally with a compiler built from TypeScriptCompiler main + #955: the three tests pass under the JIT for gc, rc and none (and
reflect_applyunder own); the full release suite under gc passes, compiled and JIT (241/242, 1 linux-only skipped);check_declarations.ps1passes. Debug builds not run locally.🤖 Generated with Claude Code