Angular 4:添加Angular材质时,cl.编译器与d.ts文件一起出现问题

时间:2017-11-09 12:28:48

标签: angular angular-material angular-compiler

我已经通过安装npm install @ angular / material和npm install @ angular / cdk添加到我的项目角度材质中,现在当我编译我的应用程序时,我收到.d.ts文件错误。

我已经检查了我的tsconfig.json文件

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "types": [ "node", "mocha", "chai" ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  },
  "exclude": [
    "node_modules",
    "wwwroot",
    "typings/main",
    "typings/main.d.ts"
  ]
}

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts",
    "typings"
  ]
}

错误:

 RROR in /node_modules/@angular/material/dialog/typings/dialog-config.d.ts (22,40): ',' expected.

    ERROR in /node_modules/@angular/material/dialog/typings/dialog-config.d.ts (22,42): Type parameter name cannot be 'any'

    ERROR in /node_modules/@angular/material/dialog/typings/dialog-container.d.ts (36,14): Generic type 'MatDialogConfig<D, any>' requires 2 type argument(s).

    ERROR in /node_modules/@angular/material/dialog/typings/dialog.d.ts (49,15): ',' expected.

    ERROR in /node_modules/@angular/material/dialog/typings/dialog.d.ts (49,17): Type parameter name cannot be 'any'

    ERROR in /node_modules/@angular/material/dialog/typings/dialog.d.ts (49,90): Generic type 'MatDialogConfig<D, any>' requires 2 type argument(s).

1 个答案:

答案 0 :(得分:1)

当你安装最新的和最新的有变化的'npm i @ angular / material'时要小心。遗憾的是,您的IDE无法预先告诉您并询问您是否要继续。

@ angular / material要求提供最新的打字稿,最新的打字稿是2.4,我认为它只适用于Angular第5版。

@ angular / cdk也是如此。

最好的是,最终,它是一个稳定的版本,而不是测试版。