If I understand correctly, rxjs
(version 5) is written in typescript and is packaged with all the definitions.
I tried using them, but I cannot seem to find a way to do that. I get the error
error TS2304: Cannot find name 'Observable'
Here is my tsconfg.json
{
"compilerOptions": {
"target": "es2016",
"strict": true
},
"exclude": [ "node_modules" ]
}
and the file I try to compile
const { Observable } = require("@reactivex/rxjs")
function timer(time: Number): Observable {
return Observable.timer(time)
}
I run node_modules/.bin/tsc test.ts
Am I missing some typescript config here? Is there something to do to enable types?
Can be due to the bug in version RxJS version 7.4.0. https://github.com/ReactiveX/rxjs/issues/6641
The typescript definitions for Observable
Subject
etc from RXJS are bundled and installed with the RXJS package. So if you run npm install rxjs
you will get the type description files (*.td) included in the npm module.
In this case I think your issue is with the import of the Observable
module. It should read:
import { Observable } from 'rxjs/Observable';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With