danday74
danday74

Reputation: 57225

rxjs Observable import issue

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

Upvotes: 3

Views: 2841

Answers (1)

cartant
cartant

Reputation: 58430

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.

Upvotes: 10

Related Questions