A TypeScript AngularJS component:
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 implemented in TypeScript:
class MyService {
constructor() {
}
public testfn(age: number) {
console.log(age);
}
}
angular
.module('app')
.service('MyService', MyService);
When I press Cmd + Click on the testfn
in WebStorm, it's not found ("No decleration to go to"). Also, the TypeScript compiler does not report an error when using testfn
with an invalid argument.
However, clicking on MyService
in static $inject
within WebStorm locates it correctly.
Is there a way to restructure this for better recognition by WebStorm and TypeScript?