Error: Return type of public method from exported class has or is using name 'ErrorObservable' from external module but cannot be named
After building out an app that is a clone of a working Angular 2 (non-cli) app, I notice several of my files are producing errors (of the same kind) now that the project is built with the Angular-CLI. I'm unclear why these are errors in the CLI version, but not in the other. Is this a Webpack-related issue? Or something to do with how Typescript is processed differently between the two builds? When I say I "built out" the app, I mean I recreated all of the components, directives, modules, routes, etc, that I had in the original app in this clone version using the CLI. This is the general error message I'm getting across several files:
Error: Return type of public method from exported class has or is using name 'ErrorObservable' from external module but cannot be named
And here's an example of a file that's listed as producing this error:
import { Observable } from 'rxjs/Observable';
import { Http, Response } from '@angular/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
@Injectable()
export class StreamAssignCommCountsService {
private _url: string = "https://api.somesite.com"
constructor(private _http: Http) {}
getCount() {
return this._http.get(this._url)
.map((response:Response) => response.json())
.catch(this._errorsHandler);
}
_errorsHandler(error: Response) {
console.error(error);
return Observable.throw(error || "Server Error");
}
}
My Setup: MacBook Air, OS X El Capitan
Angular-CLI Version Running the Angular-CLI version 1.0.0-beta.22-1
The full error trace looks like this (edited slightly for privacy):
vendor.bundle.js:52455 ./src/app/data/stream.service.ts Module build failed: Error: /Users/adds/Documents/abc/abc-cli/cli-abc/src/app/data/stream-assign.service.ts (20,5): Return type of public method from exported class has or is using name 'ErrorObservable' from external module "/Users/adds/Documents/abc/abc-cli/cli-abc/node_modules/rxjs/observable/ErrorObservable" but cannot be named.) at _checkDiagnostics (/Users/adds/Documents/abc/abc-cli/cli-abc/node_modules/@ngtools/webpack/src/loader.js:115:15) at /Users/adds/Documents/abc/abc-cli/cli-abc/node_modules/@ngtools/webpack/src/loader.js:140:17 @ ./src/app/views/stream/stream-module.ts 25:0-82 @ ./src/app/app.module.ts @ ./src/app/index.ts @ ./src/main.ts @ multi main vendor.bundle.js:52455 ./src/app/data/stream-assign.service.ts Module build failed: Error: /Users/adds/Documents/abc/abc-cli/cli-abc/src/app/data/stream-assign-comm.service.ts (20,5): Return type of public method from exported class has or is using name 'ErrorObservable' from external module "/Users/adds/Documents/abc/abc-cli/cli-abc/node_modules/rxjs/observable/ErrorObservable" but cannot be named.) at _checkDiagnostics (/Users/adds/Documents/abc/abc-cli/cli-abc/node_modules/@ngtools/webpack/src/loader.js:115:15) at /Users/adds/Documents/abc/abc-cli/cli-abc/node_modules/@ngtools/webpack/src/loader.js:140:17 @ ./src/app/views/stream/stream-module.ts 25:0-82 @ ./src/app/app.module.ts @ ./src/app/index.ts @ ./src/main.ts @ multi main
In the end, got this resolved by adjusting the following:
imported { ErrorObservable } from 'rxjs/observable/ErrorObservable';
instead of:
import 'rxjs/add/observable/throw';
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.