An AngularJS component in TypeScript:
class MyComponentCtrl {
static $inject = ['MyService'];
constructor(private MyService) {
MyService.testfn(55); // No error in typescript
}
}
class MyComponent implements ng.IComponentOptions {
constructor() {
this.controller = MyComponentCtrl;
this.template = 'hello';
}
}
angular
.module('app')
.component('MyComponent', new MyComponent());
An AngularJS service in TypeScript:
class MyService {
constructor() {
}
public testfn(age: number) {
console.log(age);
}
}
angular
.module('app')
.service('MyService', MyService);
When I hit Cmd + Click on the testfn in WebStorm, it's not found ("No decleration to go to"). Also, the TypeScript compiler is not giving error when I use testfn with invalid argument.
When I click on MyService in static $inject WebStorm finds it correctly.
Can I structure this differently somehow so WebStorm and TypeScript finds it?