本文介绍了TS7016:找不到模块“rxjs"的声明文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经升级了我的 Angular App 依赖项并成功安装了它们.不幸的是,我现在无法使用rxjs".下面是IDE返回的错误.

TS7016:找不到模块rxjs"的声明文件.C:/Path/to/project/node_modules/rxjs/dist/cjs/index.js"隐式具有any"类型.尝试 npm i --save-dev @types/rxjs 如果它存在或添加一个包含 `declare module 'rxjs' 的新声明 (.d.ts) 文件;

下面是我的package.json

{引擎":{节点":14.15.4",npm":7.11.2"},名称":furaha-app",版本":0.0.0",脚本":{ng":ng",服务":ng服务",开始":节点 server.js",构建":ng build --prod --aot",测试":ng测试",test-coverage":ng test --code-coverage",lint":ng lint",lint-fix":npm run lint --fix",e2e":ng e2e",snyk-protect":snyk 保护",准备":npm run snyk-protect"},私人":真的,依赖关系":{@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-b​​rowser":~11.2.12",@angular/platform-b​​rowser-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",引导程序":^4.6.0",快递":^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",路径":^0.12.7",pouchdb":^7.2.2",斑驴":^0.12.1",rxjs":~7.0.0",snyk":^1.574.0",tinymce":^5.7.1",tslib":^2.2.0",打字稿":4.1.5",zone.js":~0.11.1";},开发依赖":{@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",茉莉花芯":~3.7.1",jasmine-spec-reporter":7.0.0",业力":^6.3.2",karma-chrome-launcher":~3.1.0",karma-coverage-istanbul-reporter":^3.0.3",业力茉莉":~4.0.1",karma-jasmine-html-reporter":^1.5.4",karma-verbose-reporter":0.0.6",量角器":^7.0.0",ts-node":^9.1.1"},snyk":真的}

在运行 ng serve 时,我收到几个与 rxje 中的类型相关的错误,例如在下面

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

属性管道"在商店中不存在

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)))));

对象params"的类型未知

是否可以在 Angular v11 应用中使用 rxjs v7?

解决方案

没有.
请参阅相关的 github 问题 =>https://github.com/angular/angular/issues/41897

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.

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));
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)))));

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

这篇关于TS7016:找不到模块“rxjs"的声明文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 03:48
查看更多