reflect-metadata
reflect-metadata copied to clipboard
Add a `/no-conflict` export that does not mutate the global `Reflect` object
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
This PR looks ready to review and is green under CI. Should it have reviewers?
Closing in favor of #144.