Angular 错误TS2315:类型';ElementRef';不是泛型的

Angular 错误TS2315:类型';ElementRef';不是泛型的,angular,typescript,npm,angular-material,Angular,Typescript,Npm,Angular Material,我正在尝试在我的应用程序中使用@angular/materials,它正在成功编译,但我遇到以下错误: webpack: Compiled successfully. ERROR in node_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(136,20): error TS2315: Type 'ElementRef' is not generic. node_modules/@angular/materi

我正在尝试在我的应用程序中使用@angular/materials,它正在成功编译,但我遇到以下错误:

webpack: Compiled successfully.
ERROR in node_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(136,20): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(154,104): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/material/slide-toggle/typings/slide-toggle.d.ts(53,15): error TS2315: Type 'ElementRef' is not generic.
node_modules/@angular/material/slide-toggle/typings/slide-toggle.d.ts(55,18): error TS2315: Type 'ElementRef' is not generic.
这似乎不是一个常见的问题,有人知道如何解决吗

使用:

Angular CLI: 1.7.4
Node: 8.11.1
OS: win32 x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 6.0.0-rc.14-29bf024
@angular/cli: 1.7.4
@angular/material: 6.0.0-rc.14-29bf024
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

您使用的是
@angular/material
@angular/cdk
6RC版本(
6.0.0-rc.14-29bf024)
,这可能取决于angular版本6


要么将
@angular/material
包降级到最新的稳定版本(如果您是直接为生产而构建的),要么尝试将angular升级到
6.0.0-rc.6
版本(如果您是在angular 6稳定版面世后针对您的发行版)。

这是一个依赖性问题,需要重新安装依赖项

在package.json中,将您的角度版本与“@angular/material”匹配,应该是类似的。 然后跑

npm install 
这对我有用


角度版本是
5.2.1

我们遇到了相同的问题。将Angular升级到6对我们来说还不是一个选项,因为我们有一个依赖项,它不支持Angular 5之上的任何东西(目前正在重新考虑该依赖项)。将材料下载到第5版是一个选择,但并不理想,因为我们选择第6版的原因是它修复了材料标签上一个非常严重的错误

对我们有效的是将Node升级到8.10。我不知道为什么这解决了它,但它确实解决了


希望有帮助。

更新您的角度版本material和cdk的默认版本适用于angular 6,不适用于angular 5。如果升级不是一个选项,那么降级包应该是可行的。我做到了:
npm安装--save@angular/material@5.2.4
npm安装--保存@angular/cdk@5.2.4
。(我认为material和cdk的最新版本5都是5.2.4只是巧合)。我不认为这是巧合,因为它们是一起开发的。如果有人使用sdk和动画,那么也可以将它们的版本安装为5.2.1。
npm uninstall @angular/material  --save
npm install @angular/material@5.2.4 --save