Reputation: 342
I have the following imports in my "posts.service.ts"
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { NotFoundError } from '../commons/errors/not-found-error.errors';
import { AppErrors } from '../commons/errors/app-errors.errors';
import { Observable } from 'rxjs';
import { catchError } from 'rxjs/operators';
import 'rxjs/add/observable/throw';
I even checked the node_modules folder for 'rxjs/add/observable/throw' and it is available there. But I get a strange error as shown below during project compilation phase.
ERROR in ./src/app/services/posts.service.ts Module not found: Error: Can't resolve 'rxjs/add/observable/throw' in '/Users/gauthampughaz/Development/angular/practice/src/app/services'
ℹ 「wdm」: Failed to compile.
Upvotes: 8
Views: 19220
Reputation: 732
_throw is now exported as throwError.
You can do something like this if you dont want to replace every instance of _throw. (don't recommend).
import { throwError as _throw } from 'rxjs';
Or you can just change everywhere you use _throw to throwError
See other breaking changes here:
https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#breaking-changes-7
Upvotes: 1
Reputation: 96891
Since RxJS 6 you should import "creation" methods directly from 'rxjs'
:
import { throwError } from 'rxjs';
Just don't forget you need to have proper path maps set but if you're using angular-cli you don't need to worry about that. For more details see: https://github.com/ReactiveX/rxjs/blob/6.2.0/doc/pipeable-operators.md#build-and-treeshaking
Upvotes: 23