-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Related:
- SES compatibility for '--emitDecoratorMetadata' TypeScript#43463
- failed to delete intrinsics endojs/endo#612
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.