mcfly soft
mcfly soft

Reputation: 11665

Errors when importing "MatTableDataSource" from "@angular/material"

I have installed:

npm install --save @angular/material @angular/cdk @angular/animations

and tried to simply import the MatTableDataSource into my component, without using it:

import {MatTableDataSource} from "@angular/material";

I already get the following error:

ERROR in node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(79,22): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(89,29): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(103,23): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(153,30): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/a11y/typings/focus-trap/focus-trap.d.ts(133,30): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/observers/typings/observe-content.d.ts(33,22): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/observers/typings/observe-content.d.ts(67,65): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/cdk/overlay/typings/position/connected-position-strategy.d.ts(40,106): error TS2315: Type 'ElementRef' is not generic.

My versions:

Angular CLI: 1.5.6
Node: 8.9.3
OS: win32 x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 7.3.0
@angular/cli: 1.5.6
@angular/material: 7.3.0
@angular-devkit/build-optimizer: 0.0.40
@angular-devkit/core: 0.0.27
@angular-devkit/schematics: 0.0.50
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.6
@schematics/angular: 0.1.15
@schematics/schematics: 0.0.15
typescript: 2.5.3
webpack: 3.8.1

Because I don't know howto analyse this, I am asking for help here :-)

Upvotes: 2

Views: 1483

Answers (2)

I had same issue too, I installed same version of material like on angular

npm install --save @angular/[email protected] @angular/[email protected]

Upvotes: 0

Sajeetharan
Sajeetharan

Reputation: 222722

From the above package.json file it seems you are using angular 5 with angular/material 7 which would cause the issue for you.

Either downgrade the @angular/material package to the matching version ( or try upgrading angular to the 7 version

Upvotes: 2

Related Questions