>PROBLEM
The code below returns the error message:
This condition will always return 'true' since the types 'string' and 'EventEmitter<string>' have no overlap.ts(2367)
*** BAD
crossOffItem(event: EventEmitter<string>): void {
const ritems = this.items.filter( it => it !== event);
this.items = ritems;
}
>SOLUTION
TypeScript complains that the types are not explicitly equivalent or comparable.
*** OK
crossOffItem(event: EventEmitter<string>): void {
const ritems = this.items.filter( it => it !== event.toString());
this.items = ritems;
}
POOR SOLUTION
crossOffItem(event: EventEmitter<string>): void {
const val = event.toString();
const ritems = this.items.filter( it => it !== val);
this.items = ritems;
}
No comments:
Post a Comment