reflect-metadata icon indicating copy to clipboard operation
reflect-metadata copied to clipboard

Add a `/no-conflict` export that does not mutate the global `Reflect` object

Open rbuckton opened this issue 4 years ago • 1 comments

This adds a reflect-metadata/no-conflict module that can be imported rather than relying on mutation of the global Reflect object.

This can be used with TypeScript's __metadata helper when not using --importHelpers, but requires a local definition of Reflect when emitting to CommonJS/AMD/UMD/System:

// --module es2015
// --module es2020
// --module esnext
import { Reflect } from "reflect-metadata/no-conflict";
...
// --module commonjs
// --module amd
// --module umd
// --module system
import { Reflect as _Reflect } from "reflect-metadata/no-conflict";
const Reflect = _Reflect;

// which, for 'commonjs', is transformed to:
const no_conflict_1 = require("reflect-metadata/no-conflict");
const Reflect = no_conflict_1.Reflect;

Support for --importHelpers requires a custom tslib, which is out of scope for this PR.

Fixes #130

rbuckton avatar Apr 14 '21 03:04 rbuckton

This PR looks ready to review and is green under CI. Should it have reviewers?

erights avatar Jun 09 '21 05:06 erights

Closing in favor of #144.

rbuckton avatar Dec 07 '23 22:12 rbuckton