2017-05-15 161 views
4

我正在尝试使用Angular4实现“角材”。我所做的所有设置从角材料的官方网站[angular.material.io] [1]角4与材质

[1]:https://material.angular.io/guide/getting-started而是试图通过时开始NPM运行项目,收到以下错误:

node_modules/@angular/material/typings/button/button.d.ts(40,22): error TS2420: Class 'MdButton' incorrectly implements interface 'CanDisable'. Property 'disabled' is private in type 'MdButton' but not in type 'CanDisable'. node_modules/@angular/material/typings/button/button.d.ts(40,39): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdButtonBase' is not a constructor function type. node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,22): error TS2420: Class 'MdCheckbox' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdCheckbox'. node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,41): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdCheckboxBase' is not a constructor function type. node_modules/@angular/material/typings/radio/radio.d.ts(24,22): error TS2420: Class 'MdRadioGroup' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdRadioGroup'. node_modules/@angular/material/typings/radio/radio.d.ts(24,43): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdRadioGroupBase' is not a constructor function type. node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,22): error TS2420: Class 'MdSlideToggle' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdSlideToggle'. node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,44): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdSlideToggleBase' is not a constructor function type. node_modules/@angular/material/typings/slider/slider.d.ts(26,22): error TS2420: Class 'MdSlider' incorrectly implements interface 'CanDisable'. Property 'disabled' is missing in type 'MdSlider'. node_modules/@angular/material/typings/slider/slider.d.ts(26,39): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdSliderBase' is not a constructor function type.

有人请帮我解决以上问题。

+0

请正确地重新排列问题中的内容。 –

+0

一个包被破坏,它的持久状态在任何时候。不可能很快使用它们。 – Gedweb

回答

3

仔细检查你的package.json依赖和devDependencies文件并找到你的打字稿安装。确定它是2.2.0或更高。

"typescript": "~2.2.0" 

如果你做出改变,务必再运行

$ npm update -D 

如果你拥有了它在全球安装并且在您的package.json文件没有打字稿行,运行

$ npm install -g [email protected] 
0

除了上面的答案,我还添加了package.json文件的截图:

转到您的package.json,并检查依赖性和devDependies,如下图所示: package.json

步骤1:如果打字稿版本比2.2.0少,将其更改为最新vesrion为如图所示。

第二步:运行NPM更新-D在终端

第三步:要全局更新打字稿,执行以下命令:

NPM安装-g打字稿@版本号