我正在尝试在我的应用程序中使用@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 stable 出来之后发布)。
关于angular - 错误 TS2315 : Type 'ElementRef' is not generic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50134205/