I get this little error almost daily when working in Angular (Particularly in VS Code).

Type 'EventEmitter' is not generic.

The first time I got the issue, it drove me mad as I was copy and pasting code from another file where it was working just fine, yet in my new code file everything was blowing up.

As it turns out, NodeJS has it’s own version of “EventEmitter” that is not generic. When using VS Code or other IDE’s that have auto completion, they will sometimes pick this EventEmitter to import rather than the one from Angular. The way to check is to see what your import statement looks like. It should be coming from @angular/core :

import { EventEmitter } from '@angular/core';

In my (broken) case, it was :

import { EventEmitter } from 'events';

In actuality, there are a couple of EventEmitter objects. For example another half broken example would be :

import { EventEmitter } from 'stream';

So just check exactly where you are importing EventEmitter from to get around this pesky error!

Wade Developer
👋 Hey, I'm Wade
Wade is a full-stack developer that loves writing and explaining complex topics. He is an expert in Angular JS and was the owner of tutorialsforangular.com which was acquired by Upmostly in July 2022.

💬 Leave a comment

Your email address will not be published. Required fields are marked *

We will never share your email with anyone else.