Chris Tarasovs
Chris Tarasovs

Reputation: 695

Angular 4 : Cli compiler issue with d.ts file when adding Angular material

I've added to my project angular material by installing npm install @angular/material and npm install @angular/cdk and now when I compile my app I am getting .d.ts file errors.

I've checked my tsconfig.json file

{
  "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"
  ]
}

Errors:

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

Upvotes: 1

Views: 706

Answers (1)

Chris Tarasovs
Chris Tarasovs

Reputation: 695

Be careful when you do 'npm i @angular/material ' as you install the latest and the latest has breaking changes. It is a shame that your IDE can't tell you upfront and ask you if you want to take continue.

@angular/material is asking for the latest typescript, and latest typescript that is 2.4 I think is only working on Angular version 5.

The same goes for @angular/cdk.

Best thing is that finally, it is a stable version and not beta.

Upvotes: 1

Related Questions