AutoInject seems to not work
gregoryagu opened this issue · 2 comments
gregoryagu commented
Starting from the aspnetcore sample, I add a test class, then import it with autoinject. It compiles ok, but at runtime, the injection does not happen.
I can create the class manually, so it is getting compiled correctly. But through injection, it's always null.
(Note that in tsconfig.json, I comment out the "importHelpers" line, as there is a currently a TS issue with that.)
app.ts
import { autoinject, singleton } from "aurelia-framework";
import { FindMe } from "core/findme";
@autoinject()
export class AppViewModel {
constructor(private findme:FindMe) {
findme.log("here");
}
}
The js generated by ts looks like this:
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { autoinject } from "aurelia-framework";
var AppViewModel = (function () {
function AppViewModel(findme) {
this.findme = findme;
findme.log("here");
}
return AppViewModel;
}());
AppViewModel = __decorate([
autoinject()
], AppViewModel);
export { AppViewModel };
jods4 commented
I'm going to close this issue because it's unrelated to the webpack build.
From the code output I would say you don't have the emitDecoratorMetadata
option set in TS.
gregoryagu commented
Yes, you are correct. Thank you very much.