2
votes

I've tried:

import { Observable } from 'rxjs/Observable';

which gives me the error:

node_modules/rxjs/Obserable has no exported member 'Observable'

and I've tried:

import { Observable } from 'rxjs';

which gives me the TSLINT error:

This import is blacklisted

I know I can fix this by removing the 'rxjs' import-blacklist entry from tslint.json but I don't want to do that. I'm sure its there for a good reason. How do I correctly do the import? thanks

EDIT: Changed to capital O - see comment

1
What version of RxJS are you using? The latest - v6 - has far fewer import locations than v5 and 'rxjs/observable' no longer exists (and, in any case, it should have had a capital O). Instead, you should import from 'rxjs' and you should remove that import location from the blacklist. The linting rule is not appropriate for v6. See the migration guide. - cartant
brilliant answer, plz add your comment as an answer so I can accept thx PS RXJS @ v6 - danday74

1 Answers

9
votes

It sounds like you are using RxJS version 6.

In version 6, the number of import locations was greatly reduced. In particular, the 'rxjs/Observable' import no longer exists and the Observable class should be imported from 'rxjs' like this:

import { Observable } from 'rxjs';

That means the blacklist you were using is no longer appropriate for version 6 and will need to be reconfigured or disabled.

The other changes that were made to the import locations in version 6 are discussed in the migration guide - which also explains how the rxjs-compat package can be used to ease the migration from version 5 to version 6.