小咸儿最近在学习Angular的时候遇到了一个问题,再次特地总结下来,分享给大家!
[tslint]报错:Type number trivially inferred from a number literal, remove type annotation (no-inferrable-types)
问题主要显示在代码:
private rating: numbe = 0;
在查找问题的时候,发现原来是tslint觉得自己根据右边的”0”判断出rating的类型是number类型,所以认为再写number是多此一举。(看来tslint也是很智能的,但是难保不会判断错误啊!)
解决方法:tslint.json添加”ignore-properties”,即不推断类的属性(字段)

里面还有一些具体的知识和相关内容,小咸儿在这里没有进行过多的阐述,具体的参考请见:
感谢大家的访问,一起成长!
在Angular学习过程中,作者小咸儿遇到tslint错误提示:Type number trivially inferred from a number literal, remove type annotation (no-inferrable-types)。错误出现在对数字字面量赋值时,tslint尝试推断类型。解决办法是在tslint.json配置中忽略类属性的类型推断。文章鼓励读者查阅更多资料深入理解。"
108161531,9938857,VBA 用户窗体中的列表框控件详解,"['VBA', '用户界面', '窗体控件', '编程', 'Excel']
4794

被折叠的 条评论
为什么被折叠?



