Skip to content

Reflect: get, set, has, ownKeys, deleteProperty, isExtensible, preventExtensions, apply, construct - #110

Merged
ASDAlexander77 merged 1 commit into
mainfrom
reflect
Nov 20, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
reflect

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Reflect as a namespace of generic functions in lib.generics.ts, like Atomics.

Merge after ASDAlexander77/TypeScriptCompiler#955: Reflect.ownKeys of a class uses Object.keys of any, which that PR adds. tests/reflect_keys.ts fails 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):

Method Behaviour
get, has a class's public fields, accessors and methods (of its actual class), an object literal's or tuple's fields, an array's indices; protected fields not seen; get gives any
ownKeys what Object.keys gives: public fields, base class first; no accessors, methods or "length"
set false for a key the object has not, a value its type does not take, or an object literal (a copy as any); null throws
deleteProperty true only of a key that is not there
isExtensible / preventExtensions false / true: no object can gain a key
apply, construct arguments of mixed types; thisArgument not used

Not here (no prototypes or descriptors): getPrototypeOf, setPrototypeOf, defineProperty, getOwnPropertyDescriptor.

Under -mm=own the key operations are compile errors (any has no keys), and construct can't give a constructor a string or object from the lent arguments array; apply, isExtensible and preventExtensions work.

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_apply under own); the full release suite under gc passes, compiled and JIT (241/242, 1 linux-only skipped); check_declarations.ps1 passes. Debug builds not run locally.

🤖 Generated with Claude Code

…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>
@ASDAlexander77
ASDAlexander77 merged commit 398ec0e into main Nov 20, 2026
3 of 9 checks passed
@ASDAlexander77 ASDAlexander77 changed the title Reflect: get, set, has, ownKeys, deleteProperty, isExtensible, preventExtensions, apply, construct Reflect: get, set, has, ownKeys, isExtensible, preventExtensions, apply, construct; the rest throw not available Nov 20, 2026
@ASDAlexander77 ASDAlexander77 changed the title Reflect: get, set, has, ownKeys, isExtensible, preventExtensions, apply, construct; the rest throw not available Reflect: get, set, has, ownKeys, deleteProperty, isExtensible, preventExtensions, apply, construct Nov 20, 2026
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