svi3c svi3c - 3 months ago 36
TypeScript Question

IntelliJ IDEA does not find operators of Observable in rxjs5

I just installed rxjs 5 beta 3 via

npm i rxjs@5.0.0-beta.3
.

I have the following example code:

import {Observable} from "rxjs"

new Observable(o => o.next(42)).filter(() => true);


This code compiles perfectly well when using ts-node for example.

But when looking at this code inside IntelliJ IDEA, the
filter()
operator is not found.

When using operators on an Observable instance, they are not found either.

The suggested static members of
Observable
are:


  • create()

  • if()

  • throw()



The suggested members of an instance of
Observable
are:


  • _isScalar()

  • forEach()

  • lift()

  • subscribe()



I also tried to import only what I need, but still my IDE tells me that
filter()
does not exist on the Observable instance:

import {Observable} from "rxjs/Observable"
import "rxjs/add/operator/filter"

new Observable(o => o.next(42)).filter(() => true);


Any suggestions how to make IntelliJ IDEA know about the operators?

Answer

Please, check IDEA 2016.1.2 or higher

Note: Directory node_modules must be not excluded from the project.
Otherwise, see answer http://stackoverflow.com/a/38499577/1057218

Note 2: File package.json must contain the direct dependency (or devdependency) 'rxjs'