2017-05-15 169 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打字稿@版本號