angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

importing anything from `@angular/router` breaks EventEmitter

Open coxjonc opened this issue 10 years ago • 3 comments

System

OS: Mac OSX El Capitan Node: 6.3.0 Angular CLI: 1.0.0-beta.9 angular-router: 3.0.0-beta.2

Repro

This is a problem in an app created with the CLI.

My build compiles fine without any imports from angular-router, but if I add import {} from '@angular/router' in my code, I get the following error:

'Type EventEmitter<{}> is not assignable to type 'EventEmitter<string>'

In the constructor function I declare new EventEmitter variables like so: x: EventEmitter<string>. I instantiate the event emitter like so: x = new EventEmitter();.

This usually works fine, but when I import from angular/router it goes haywire.

Here's the code in my constructor function that causes the hangup:

x = EventEmitter<string>;
...
constructor() {
  this.x = new EventEmitter();
}

My package.json is attached

coxjonc avatar Jul 13 '16 16:07 coxjonc

Try

this.x = new EventEmitter<string>();

p.s. I'm pretty sure this is not really an issue with angular-cli and the question should be on stack overflow or somewhere like that.

slmyers avatar Jul 14 '16 06:07 slmyers

OK got it. Thanks!

coxjonc avatar Jul 15 '16 20:07 coxjonc

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.