【发布时间】:2018-11-11 23:28:18
【问题描述】:
我从https://material.angular.io/components/chips/overview复制了以下代码:
visible: boolean = true;
selectable: boolean = true;
removable: boolean = true;
addOnBlur: boolean = true;
// Enter, comma
separatorKeysCodes = [ENTER, COMMA];
fruits = [
{ name: 'Lemon' },
{ name: 'Lime' },
{ name: 'Apple' },
];
add(event: MatChipInputEvent): void {
let input = event.input;
let value = event.value;
// Add our fruit
if ((value || '').trim()) {
this.fruits.push({ name: value.trim() });
}
// Reset the input value
if (input) {
input.value = '';
}
}
remove(fruit: any): void {
let index = this.fruits.indexOf(fruit);
if (index >= 0) {
this.fruits.splice(index, 1);
}
}
但我收到以下错误:
- TSLint:从布尔文字中简单地推断出布尔类型,删除类型注释(不可推断类型)
- 未使用的字段可见
- TSLint:永远不会重新分配标识符“值”;使用“常量”而不是“让”。 (首选常量)
为什么会出现这些错误?我不认为这是 Angulars 的错。所以我一定是做错了什么?!
【问题讨论】:
标签: angular angular-material phpstorm