Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TS7016: Could not find a declaration file for module 'rxjs'

I have upgraded my Angular App dependency and successfully installed them. Unfortunately I am now unable to use 'rxjs'. Below is the error returned by the IDE.

TS7016: Could not find a declaration file for module 'rxjs'.'C:/Path/to/project/node_modules/rxjs/dist/cjs/index.js' implicitly has an 'any' type.   Try npm i --save-dev @types/rxjs if it exists or add a new declaration (.d.ts) file containing `declare module 'rxjs';

Below is my package.json

{
  "engines": {
    "node": "14.15.4",
    "npm": "7.11.2"
  },
  "name": "furaha-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "serve": "ng serve",
    "start": "node server.js",
    "build": "ng build --prod --aot",
    "test": "ng test",
    "test-coverage": "ng test --code-coverage",
    "lint": "ng lint",
    "lint-fix": "npm run lint --fix",
    "e2e": "ng e2e",
    "snyk-protect": "snyk protect",
    "prepare": "npm run snyk-protect"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/architect": "^0.1102.9",
    "@angular-devkit/build-angular": "~0.1102.11",
    "@angular/animations": "~11.2.12",
    "@angular/cdk": "^11.2.11",
    "@angular/cli": "~11.2.11",
    "@angular/common": "~11.2.12",
    "@angular/compiler": "~11.2.12",
    "@angular/compiler-cli": "~11.2.12",
    "@angular/core": "~11.2.12",
    "@angular/forms": "~11.2.12",
    "@angular/platform-browser": "~11.2.12",
    "@angular/platform-browser-dynamic": "~11.2.12",
    "@angular/pwa": "^0.1102.11",
    "@angular/router": "~11.2.12",
    "@angular/service-worker": "^11.2.12",
    "@dimakorotkov/tinymce-mathjax": "^1.0.7",
    "@ng-select/ng-select": "^6.1.0",
    "@ngrx/component": "^11.1.1",
    "@ngrx/effects": "^11.1.1",
    "@ngrx/entity": "^11.1.1",
    "@ngrx/store": "^11.1.1",
    "@ngrx/store-devtools": "^11.1.1",
    "@ngx-translate/core": "^13.0.0",
    "@tinymce/tinymce-angular": "^4.2.2",
    "@types/mathjax": "0.0.36",
    "@types/pouchdb": "^6.4.0",
    "bootstrap": "^4.6.0",
    "express": "^4.17.1",
    "flag-icon-css": "^3.5.0",
    "google-libphonenumber": "^3.2.19",
    "mathjax": "^3.1.4",
    "ng2-pdf-viewer": "^6.4.1",
    "ngx-bootstrap": "^6.2.0",
    "ngx-duration-picker": "^3.2.0",
    "ngx-mathjax": "0.0.13",
    "path": "^0.12.7",
    "pouchdb": "^7.2.2",
    "quagga": "^0.12.1",
    "rxjs": "~7.0.0",
    "snyk": "^1.574.0",
    "tinymce": "^5.7.1",
    "tslib": "^2.2.0",
    "typescript": "4.1.5",
    "zone.js": "~0.11.1"
  },
  "devDependencies": {
    "@angular-eslint/builder": "^4.2.0",
    "@angular-eslint/eslint-plugin": "^4.2.0",
    "@angular-eslint/eslint-plugin-template": "^4.2.0",
    "@angular-eslint/schematics": "^4.2.0",
    "@angular-eslint/template-parser": "^4.2.0",
    "@angular/language-service": "~11.2.12",
    "@ngrx/schematics": "^11.1.1",
    "@types/jasmine": "^3.6.10",
    "@types/jasminewd2": "~2.0.8",
    "@types/node": "^15.0.1",
    "@typescript-eslint/eslint-plugin": "4.22.0",
    "@typescript-eslint/parser": "4.22.0",
    "eslint": "^7.25.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "33.0.0",
    "eslint-plugin-prefer-arrow": "1.2.3",
    "jasmine-core": "~3.7.1",
    "jasmine-spec-reporter": "7.0.0",
    "karma": "^6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "karma-verbose-reporter": "0.0.6",
    "protractor": "^7.0.0",
    "ts-node": "^9.1.1"
  },
  "snyk": true
}

On running ng serve I receive several errors related to types in rxje e.g in the below

this.genders$ = this.store.pipe(select(selectGenders));

property 'pipe' does not exist on Store

this.teacherProfile$ = this.route.parent?.paramMap
      .pipe(map(params => Number(params.get('id'))))
      .pipe(tap(id => this.teacherId = id))
      .pipe(mergeMap((id) => this.store.pipe(select(selectTeacher(id)))));

Object 'params' is of type unknown

Is it possible to use rxjs v7 in an Angular v11 app?

like image 562
Owen Kelvin Avatar asked May 01 '21 19:05

Owen Kelvin


People also ask

How to fix could not find declaration file for module'react'?

Fix - Could not find declaration file for module 'react'# The error "could not find declaration file for module 'react'" occurs when TypeScript cannot find the type declaration for a react-related module. To solve the error install the types for the module by running the command from the error message, e.g. npm install -D @types/react.

How to fix ts7016 error in typescript?

The ideal solution is right in the TS7016 error message: npm install @types/your-package-of-interest. This pulls from a special NPM username, @types, where people publish TypeScript declarations separately from the packages they declare.

Could not find declaration file for module in typescript?

The error "Could not find declaration file for module" occurs when TypeScript cannot find the type declaration for a module. To solve the error, install the types for the module by running the command from the error message, e.g. npm install -D @types/module-name . The error message shows the command you should try to run when you get the error.

How to fix “ module is not yours” error when importing?

Suppose your module files are stored in dist folder then try remove .js extension from "main" key in package.json – Also, you can try adding typings key to the package.json file – If the module in which you are getting error, is not yours then you may try this command – If you get error in the above command, you can change the import to require –


1 Answers

Is it possible to use rxjs v7 in an Angular v11 app?

no.
see the related github issue => https://github.com/angular/angular/issues/41897

like image 62
Ammar Avatar answered Nov 15 '22 04:11

Ammar