ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305:

I had same issue, I had to downgrade rxjs-compat(6.3.3) to align it with rxjs(6.3.3),

In your package.json it should be like:

"rxjs": "6.3.3",
"rxjs-compat": "6.3.3",

If you are using rxjs 6.4.0, you don't need to use rxjs-compat, which provides a compatibility layer between rxjs v6 and v5.

So I think you can directly use import { shareReplay } from 'rxjs/operators';

More information on the operators here: https://www.learnrxjs.io/


I had the same issue for the project where versions of rxjs and rxjs-compat were different in package.json file as rxjs="6.3.3" and rxjs-compat="6.4.0" so I just downgraded the rxjs-compat version by following command:

npm install [email protected] --s

it worked for me.


I faced identical issue with "rxjs": "6.3.3","rxjs-compat": "6.4.0" and despite moving to version ^6.3.3 the error remained. Just a small addition. If you have ^ in your rxjs-compat it may cause problem. Without the caret, i.e. rxjs-compat": "6.3.3" it worked for me. Refer https://github.com/ReactiveX/rxjs/issues/4512. Thanks