Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I am trying to upgrade a basic angular skeleton app from angular 5 to angular 6 and here's the issue I am coming across when trying to run the app :

ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305: Module '"C:/newAdmin/testing-front-end/admin-fe/node_modules/rxjs/internal-compatibility/index"' has no exported member 'ShareReplayConfig'.

Here is my package.json :

{
 "name": "admin-fe",
 "version": "0.0.0",
 "scripts": {
 "ng": "ng",
 "start": "ng serve",
 "build": "ng build",
 "test": "ng test",
 "lint": "ng lint",
 "e2e": "ng e2e"
 },
 "private": true,
 "dependencies": {
   "@angular-devkit/core": "^7.3.0",
   "@angular/animations": "^6.1.0",
   "@angular/common": "^6.1.0",
   "@angular/compiler": "^6.1.0",
   "@angular/core": "^6.1.0",
   "@angular/forms": "^6.1.0",
   "@angular/http": "^6.1.0",
   "@angular/platform-browser": "^6.1.0",
   "@angular/platform-browser-dynamic": "^6.1.0",
   "@angular/router": "^6.1.0",
   "@ngrx/store": "^7.2.0",
   "angular-oauth2-oidc": "^5.0.2",
   "core-js": "^2.5.4",
   "moment": "^2.24.0",
   "rxjs": "6.3.3",
   "rxjs-compat": "^6.4.0",
   "zone.js": "~0.8.26"
  },
  "devDependencies": {
   "@angular-devkit/build-angular": "~0.7.0",
   "@angular/cli": "~6.1.3",
   "@angular/compiler-cli": "^6.1.0",
   "@angular/language-service": "^6.1.0",
   "@types/jasmine": "~2.8.6",
   "@types/jasminewd2": "~2.0.3",
   "@types/node": "~8.9.4",
   "codelyzer": "~4.2.1",
   "jasmine-core": "~2.99.1",
   "jasmine-spec-reporter": "~4.2.1",
   "karma": "~1.7.1",
   "karma-chrome-launcher": "~2.2.0",
   "karma-coverage-istanbul-reporter": "~2.0.0",
   "karma-jasmine": "~1.1.1",
   "karma-jasmine-html-reporter": "^0.2.2",
   "protractor": "~5.3.0",
   "ts-node": "~5.0.1",
   "tslint": "~5.9.1",
   "typescript": "^2.9.1"
 }
}

I do not get this error when using typescript 3.3.1 but I cannot use that since the compiler will only allow me till typescript < v2.10.0

What steps can I take here ?

EDIT :

I aligned both the rxjs and rxjs-compat versions to be 6.3.3 but now I am getting the following error:

ERROR in node_modules/@ngrx/store/src/store.d.ts(30,31): error TS2304: Cannot find name 'Extract'.
like image 806
jackfr0st Avatar asked Feb 02 '19 12:02

jackfr0st


2 Answers

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/

like image 56
pk_code Avatar answered Sep 22 '22 09:09

pk_code


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.

like image 22
Omkar Waghe Avatar answered Sep 22 '22 09:09

Omkar Waghe