后续属性声明必须在以下类型中具有相同的类型错误:node_modules/@types/jquery/index.d.ts

时间:2019-04-14 11:34:47

标签: angular typescript webpack

突然,当尝试使用webpack和AOT创建构建时,出现以下错误:

  

node_modules/@types/jquery/index.d.ts(8186,5)中的错误:错误TS2717:后续属性声明必须具有相同的类型。属性“ char”必须为“ string”类型,但此处为“ any”类型。   node_modules/@types/jquery/index.d.ts(8188,5):错误TS2717:后续属性声明必须具有相同的类型。属性“键”的类型必须为“字符串”,但此处的类型为“任意”。

我已经阅读了有关此问题的一些讨论,但没有发现有什么帮助我的。

1)尝试使用“ npm prune”清除节点模块,然后安装npm。

How to clean node_modules folder of packages that are not in package.json?

2)跟随https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-typeshttps://github.com/ionic-team/ionic-cli/issues/3541来检查类型:[]在我的tsconfig中:

{
   "compilerOptions": {
      "allowJs": true,
      "module": "es6",
      "target": "es5",
      "baseUrl": "/",
      "declaration": false,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": [
         "dom",
         "es7"
      ],
      "mapRoot": "./",
      "moduleResolution": "node",
      "outDir": "dist/out-tsc",
      "sourceMap": true,
      "typeRoots": [
         "node_modules/@types",
         "hammerjs"
      ],
      "types": [
         "node",
         "jasmine"
      ]
   },

我不明白为什么我会从Jquery文件中得到错误,因为如果我理解正确的话,它们不应该包含在编译中。...

3)我什至试图跟随错误并将“ any”更改为“ string”类型,然后看看会发生什么。结果是部分构建,只有1个js块安装了5

这是我对package.json的依赖:

    "dependencies": {
        "@angular-mdl/core": "^6.0.0",
        "@angular/animations": "^6.1.7",
        "@angular/cdk": "^6.1.0",
        "@angular/common": "^6.1.9",
        "@angular/compiler": "^6.0.0",
        "@angular/core": "^6.0.0",
        "@angular/forms": "^6.0.0",
        "@angular/http": "^6.0.0",
        "@angular/material": "^6.1.0",
        "@angular/platform-browser": "^6.0.0",
        "@angular/platform-browser-dynamic": "^6.0.0",
        "@angular/platform-server": "^6.0.0",
        "@angular/router": "^6.0.0",
        "@angular/upgrade": "^6.0.0",
        "@auth0/angular-jwt": "^1.1.0",
        "@ng-bootstrap/ng-bootstrap": "^2.0.0",
        "@swimlane/ngx-charts": "^7.0.1",
        "@types/adal-angular": "^1.0.1",
        "angular": "^1.6.9",
        "angular-font-awesome": "*",
        "angular2-focus": "^1.1.2",
        "angular2-highcharts": "^0.5.5",
        "chart.js": "^2.7.2",
        "clone-deep": "^4.0.0",
        "core-js": "^2.4.1",
        "d3": "^4.13.0",
        "deep-equal": "^1.0.1",
        "file-saver": "^1.3.8",
        "font-awesome": "^4.7.0",
        "hammerjs": "^2.0.8",
        "i": "^0.3.6",
        "is-deep-equal": "^1.0.3",
        "jquery": "^3.3.1",
        "jsonwebtoken": "^8.2.0",
        "jwt-decode": "^2.2.0",
        "material-design-icons": "^3.0.1",
        "microsoft-adal-angular6": "^1.3.0",
        "moment": "^2.23.0",
        "moment-with-locales-es6": "^1.0.1",
        "ng-inline-svg": "^6.0.0",
        "ng2-completer": "^1.6.3",
        "ng2-dropdown-multiselect": "^1.2.0",
        "ng2-file-upload": "^1.3.0",
        "ng2-kw-gauge": "^0.0.8",
        "ng2-password-strength-bar": "^1.2.0",
        "ng2-select": "^2.0.0",
        "ngc": "^1.0.0",
        "ngx-bootstrap": "^2.0.3",
        "ngx-pipes": "^2.1.2",
        "ngx-popper": "^2.7.1",
        "npm": "^6.9.0",
        "object-fit-images": "^3.2.3",
        "object-hash": "^1.3.0",
        "popper.js": "^1.14.4",
        "primeicons": "^1.0.0-beta.10",
        "primeng": "^6.1.2",
        "request": "^2.88.0",
        "rxjs": "^6.3.3",
        "rxjs-compat": "^6.1.0",
        "tether": "^1.4.5",
        "ts-helpers": "^1.1.2",
        "webpack": "^4.8.3",
        "zone.js": "^0.8.5"
    },

能否请您帮我定位问题?我怎么知道是什么原因造成的,如果确实是由两种类型的冲突引起的,我怎么知道哪个文件是问题的根源?

0 个答案:

没有答案