I am new to Typescript and Aurelia. I am trying to make @autoinject decorator work in a VS2015 ASP.NET MVC 6 project.
Here is my code
import {autoinject} from "aurelia-framework"; import {HttpClient} from "aurelia-http-client"; @autoinject() export class App { http: HttpClient; constructor(httpClient: HttpClient) { this.http = httpClient; } activate() { this.http.get("/api/test/")... } }
when i run this i get this.http undefined error message.
It seems to me that I need to add the Typescript flag emitDecoratorMetadata, but I do not know how to do this.
I tried to add the tsconfig.json file to my project and set this flag in the compiler options, but then I get a bunch of errors (duplicate identifier). How can I fix these errors. Do I need to add something to the "files"? What exactly?
Here is my config.js file
System.config({ baseURL: "/", defaultJSExtensions: true, transpiler: "typescript", paths: { "npm:*": "jspm_packages/npm/*", "github:*": "jspm_packages/github/*" }, map: { "aurelia-bootstrapper": "npm: aurelia-bootstrapper@1.0.0-beta.1 ", "aurelia-framework": "npm: aurelia-framework@1.0.0-beta.1.0.7 ", "aurelia-http-client": "npm: aurelia-http-client@1.0.0-beta.1 ", "typescript": "npm: typescript@1.7.5 ", .... } });
source share