Skip to content

Importable version of reflect-metadata that does not shim globals. #130

@rbuckton

Description

@rbuckton

Related:

The various APIs added to Reflect by reflect-metadata are incompatible with SES. One option is to introduce an "importable" version that can still work with TypeScript's --emitDecoratorMetadata option:

// --module esnext
// --module es2020
// --module es2015
import { Reflect } from "reflect-metadata/no-conflict";

// --module system
// --module commonjs
// --module amd
// --module umd
import { Reflect as _Reflect } from "reflect-metadata/no-conflict";
const Reflect = _Reflect; // unfortunately necessary due to how TypeScript emits import aliases to preserve live bindings.

This version of Reflect would wrap the built-in global Reflect object so that existing TypeScript emit for the __metadata helper can continue to work while allowing access to global Reflect functionality.

@erights: Unfortunately, I cannot change the default behavior of the main module without it being a major breaking change. Is it possible to detect whether code is running in an SES environment so as not to attempt mutation of the global Reflect? If that's the case, I could investigate a hybrid approach that still performed shimming when non in an SES environment, but also provided exports for the various methods.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions