abraham / reflection

Lightweight (3K) ES Module implementation of reflect-metadata
https://www.npmjs.com/package/@abraham/reflection
MIT License
265 stars 14 forks source link

Setup tests with several frameworks #67

Closed abraham closed 1 year ago

abraham commented 5 years ago

Add an examples directory with a simple app of each of the following frameworks/libraries. The samples should make use of Reflection and have their tests run on CI. This will provide examples for developers of those libraries and make sure Reflection doesn't break compatibility. Lerna might be a good choice to manage the examples.

elderapo commented 5 years ago

Doesn't work with InversifyJS

import "@abraham/reflection";
import { Container, injectable } from "inversify";

const myContainer = new Container();

const TYPES = {
  Ninja: Symbol("Ninja")
};

@injectable()
class Ninja {}

myContainer.bind<Ninja>(TYPES.Ninja).to(Ninja);

const ninja = myContainer.get<Ninja>(TYPES.Ninja);

Error:

Uncaught TypeError: Reflect.hasMetadata is not a function
    at _postConstruct (instantiation.js:24)
    at Object.resolveInstance (instantiation.js:47)
    at resolver.js:72
    at Object.resolve (resolver.js:96)
    at container.js:319
    at Container../node_modules/inversify/lib/container/container.js.Container._get (container.js:310)
    at Container../node_modules/inversify/lib/container/container.js.Container.get (container.js:230)
    at Object../src/inversifytest.ts (inversifytest.ts:15)
    at __webpack_require__ (bootstrap ee47681dc696ba0b4a90:678)
    at fn (bootstrap ee47681dc696ba0b4a90:88)
    at Object../src/index.tsx (index.tsx:1)
    at __webpack_require__ (bootstrap ee47681dc696ba0b4a90:678)
    at fn (bootstrap ee47681dc696ba0b4a90:88)
    at Object.0 (inversifytest.ts:15)
    at __webpack_require__ (bootstrap ee47681dc696ba0b4a90:678)
    at bootstrap ee47681dc696ba0b4a90:724
    at bootstrap ee47681dc696ba0b4a90:724

I tested it within webpack but error is pretty clear. @abraham/reflection doesn't define Reflect.hasMetadata.

abraham commented 5 years ago

@elderapo please create a new issue for that. This feature request is for tracking adding additional framework tests.