AngularJS TypeScript Service Error

Viewed 754

I'm getting this error trying to add a service to a module. Can someone help point out what's wrong?

Angular 1.5.11 and TypeScript 2.2.2

ERROR in ./source/mainModule.ts
(185,33): error TS2345: Argument of type 'typeof AwesomeService ' is not 
assignable to parameter of type 'Injectable<Function>'.
Type 'typeof AwesomeService ' is not assignable to type '(string | Function)[]'.
Property 'push' is missing in type 'typeof AwesomeService '.

Here is where I'm trying to add the service

export default angular.module('iris.service', [])
    /* This line throws the error --> */.service('awesomeService', AwesomeService);

In a separate file, here is how I'm creating the service

export class AwesomeService extends OtherClass {

    private static $inject = ['configService'];

    constructor() {
        super();
    }
}

update:

I see that if I change AwesomeService to a function and export that, it works fine. Is there any way I can use a class for a Service? It looks like @types/angular specifies that the second argument to angular.module.service should be either a string or a function.

1 Answers
Related