Skip to content

Why must ProxyHandler’s ownKeys(…) method’s return value contain only strings or symbols? #1804

Open
@ExE-Boss

Description

@ExE-Boss

A lot of JavaScript user code assumes that you can pass arbitrary values where JavaScript expects property keys.

Examples:
  • Object.defineProperty(…)
  • Object.getOwnPropertyDescriptor(…)
  • Reflect.defineProperty(…)
  • Reflect.deleteProperty(…)
  • Reflect.get(…)
  • Reflect.getOwnPropertyDescriptor(…)
  • Reflect.has(…)
  • Reflect.set(…)

This makes [[ProxyHandler]].ownKeys(…) into a footgun, as user code might assume that the contents of the returned array‑like will be processed by ToPropertyKey(…), instead of throwing when it encounters a value that is neither a string, nor a symbol, like it does currently.


See also: microsoft/TypeScript#35594

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions