Why does the IDE see rxjs types as any

187 Views Asked by At

All I did was just install rxjs with npm i rxjs

Every time I wrote a Behavior... and pressed tab, the IDE would import the BehaviorSubject type from the "rxjs/dist/types" directory. And this is a bare type that does not have any execution logic.

To make the code work, you need to import the class with the code - just from "rxjs", but then another problem. The IDE thinks that all types from there are any. If you return subject from the function, the function will say that it returns any.

If you explicitly set the type of any variable, it will also say that it is any.

P.S. I use WebStorm

enter image description here

1

There are 1 best solutions below

2
Robert Rendell On

What IDE are you using?

You might find an answer here? How to import RXJS types for TypeScript

Seems to work for me in VSCode

import { BehaviorSubject } from 'rxjs'; enter image description here