Skip to main content
Notice removed Draw attention by Spencer
Bounty Ended with Aluan Haddad's answer chosen by Spencer
Notice added Draw attention by Spencer
Bounty Started worth 100 reputation by Spencer
added 279 characters in body
Source Link
Spencer
  • 2.3k
  • 3
  • 28
  • 50

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.

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(); } } 

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.

added 39 characters in body
Source Link
Spencer
  • 2.3k
  • 3
  • 28
  • 50

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(); } } 

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

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(); } } 

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(); } } 
Source Link
Spencer
  • 2.3k
  • 3
  • 28
  • 50

AngularJS TypeScript Service Error

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

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(); } }