💻 Tech
This is more of being caution when using auto-import feature of VS Code. In my case, when I was using EventEmitter, because EventEmitter
wasn’t imported, I hit CTRL+Enter then hit Enter again on the first suggestion to import, then I encountered an error. I realized later on that I imported EventEmitter
from the wrong package (stream
); it should be from @angular/core
instead.
Code:
const eventEmitter: EventEmitter<string[]>;
Error:
Type 'string[]' does not satisfy the constraint 'EventMap<string[]>'.
Type 'string[]' is not assignable to type 'Record<keyof string[], any[]>'.
Types of property '[iterator]' are incompatible.
Type '() => IterableIterator<string>' is not assignable to type 'any[]'.
// import { EventEmitter } from 'stream'; // Wrong package
import { EventEmitter } from '@angular/core'; // Correct package