Closed bodograumann closed 5 years ago
After digging into issue #6 a little more, I found the following problem. I have created a simple example in https://github.com/bodograumann/vuex-inject-modules-example.
When defining a class through:
import { decorate, inject, injectable } from "inversify"; import { RegisterOptions, Module, VuexModule } from "vuex-class-modules"; decorate(injectable(), VuexModule); @injectable() export default class VuexExampleModule extends VuexModule { constructor(@inject("VuexModuleOptions") options: RegisterOptions) { super(options); } get testString() { return "foo bar"; } }
inversify adds metadata to the class. In particular, calling
Reflect.getMetadata("inversify:tagged", VuexExampleModule);
gives
{ 0: [{ key: "inject", value: "VuexModuleOptions" }] }
Unfortunately, when now applying the @Module decorator as well, the metadata is not there anymore:
@Module
[…] @Module @injectable() export default class VuexExampleModule extends VuexModule { constructor(@inject("VuexModuleOptions") options: RegisterOptions) { […]
Now the above reflection call returns undefined.
undefined
Maybe the comments in the reflect-metadata readme are relevant.
After digging into issue #6 a little more, I found the following problem. I have created a simple example in https://github.com/bodograumann/vuex-inject-modules-example.
When defining a class through:
inversify adds metadata to the class. In particular, calling
gives
Unfortunately, when now applying the
@Module
decorator as well, the metadata is not there anymore:Now the above reflection call returns
undefined
.