I am trying to implement "Angular-Material" with Angular4. I made all setup from official site of angular material [angular.material.io][1]
[1]: https://material.angular.io/guide/getting-started but when trying to run project by npm start, getting following error:
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.
Somebody, please help me to fix above.
Double check your package.json dependencies and devDependencies file and find your typescript install. Make certain it is 2.2.0 or greater.
"typescript": "~2.2.0"
If you make a change, be sure to then run
$ npm update -D
If you have it installed globally and there is no typescript line in your package.json file, run
$ npm install -g typescript@2.2.0
In addition to above answer, i have added the screenshot of package.json file :
Go to your package.json and check dependencies and devDependies as shown below: package.json
Step 1: If the typescript version is less than 2.2.0 , change it to the latest vesrion as shown in the image.
Step2: Run npm update -D in your terminal
Step3: To globally update the typescript , execute following command:
npm install -g typescript@version-number
来源:https://stackoverflow.com/questions/43973533/angular-4-with-material