Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change typing to have EventEmitter2 extends from EventEmitter #216

Open
unional opened this issue Jun 21, 2017 · 3 comments
Open

Change typing to have EventEmitter2 extends from EventEmitter #216

unional opened this issue Jun 21, 2017 · 3 comments

Comments

@unional
Copy link

unional commented Jun 21, 2017

Currently EventEmitter2 can't be assigned directly to a EventEmitter interface:

import events = require('events')
import { EventEmitter2, Listener } from 'eventemitter2'

let e: events.EventEmitter
let e2 = new EventEmitter2()
e = e2; // error, can't assign because addListener function is not compatiable

type addListener = (event: string | symbol, listener: Function) => events.EventEmitter
type addListener2 = (event: string, listener: Listener) => EventEmitter2

let l1: addListener = ...
let l2: addListener2
y = x; // same error

Makes EventEmitter2 implements events.EventEmitter could fix this issue.

declare class EventEmitter3 implements events.EventEmitter {
  addListener(event: string | symbol, listener: Function): this
}

let e3 = new EventEmitter3
e = e3; // no error
@RangerMauve
Copy link
Contributor

Typescript hasn't been getting much love by us maintainers, but a pull request for this change would be welcome. :D

@unional
Copy link
Author

unional commented Jun 22, 2017

I can do that. Do you mind I add typescript as a devDeps so I can add a few tests?

@RangerMauve
Copy link
Contributor

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants