I got a problem with typescript and RxJs v5.
I did yarn add @reactivex/rxjs
(also yarn add rxjs
) and on my index.ts did import Rx from '@reactivex/rxjs';
and got this error:
Also, if I run node ./node_modules/.bin/tsc
I got this error back too error TS2307: Cannot find module '@reactivex/rxjs'.
Also doing
import { Observable } from 'rxjs/Observable'
Well this seems to be more related to TS itself than to RxJS.
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"outDir": "dist",
"target": "es2015",
"noImplicitAny": true,
"noEmit": true,
"strictNullChecks": true,
"suppressExcessPropertyErrors": false,
"suppressImplicitAnyIndexErrors": false,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"lib": [
"es2015",
"dom"
]
}
Having this ^ configuration seems to fix the VSCode issues, but running tsc
against src/index.ts
doesn't work
node_modules/rxjs/Observable.d.ts(69,60): error TS2693: 'Promise' only refers to a type, but is being used as a value here.
Try setting the "moduleResolution": "node"
inside your compileOptions
to specify module resolution strategy for TS.
npm install rxjs --save
and in your Typescript
import { Observable } from 'rxjs/Rx';
That fixed it for me.