I am trying to create typescript definitions for an Angular 2 project that I am working on so that it can be an exported library.
I have several services that return HTTP requests to components, everything is very similar to the following:
public create(user:User) { return this.http.post(this._apiUrls.create, JSON.stringify(user), { headers: this.apiConfig.getApiHeaders() }); }
That I then call something like this from the component:
Session.create(user).subscribe((res:Response) => { this.user = res.json().user });
All this works fine until I return the 'declaration' to true in the tsconfig file so that I can create typescript definition files. I am starting to get the following errors for several of my services:
error TS4053: Return type of public method from exported class has or is using name 'Observable' from external module "node_modules/rxjs/Observable" but cannot be named.
I basically understand the problem, but I do not know the solution. If I import an Observable into a service, then the typescript linter will cause errors, because technically it is not used in this file.
Starting with Angular 1, it was a similar paradigm that we used in all our applications to break our code, but maybe I need to change the approach in Angular 2? I looked through many other Angular 2 examples, and they all did it in a similar way.
source share