1

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).
3
  • Can you post your angular-cli.json file? What version of Typescript are you using? Commented Nov 9, 2017 at 13:15
  • How about your component code? It may be causing the problem. Commented Nov 10, 2017 at 4:26
  • the issue is TO BE CAREFULL WHEN YOU DO NPM I, as you may install breaking changes, like getting the latest material for version 5, but you got version 4 :D Commented Nov 13, 2017 at 10:31

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.