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

fix numbers as event names #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sertonix
Copy link

Problem:

class Foo extends (EventEmitter as new () => TypedEmitter<{1: () => void}>) {
    constructor() {
        super();
        this.emit("1"); // error  should be no error
    }
}

After fix:

class Foo extends (EventEmitter as new () => TypedEmitter<{1: () => void}>) {
    constructor() {
        super();
        this.emit("1"); // no error
        this.emit(1); // no error
        // a number as event name also works in node but for some reason it is not documented like that
    }
}

class Bar extends (EventEmitter as new () => TypedEmitter<{
    "1": () => void,
}>) {
    constructor() {
        super();
        this.emit("1"); // no error
        this.emit(1); // no error
        
        // known issue:
        this.emit(3); // no error
        // I found no way to get the number from a string
        // but the arguments are typed correctly:
        this.emit(3,""); // error
    }
}

(redo from #33)

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

Successfully merging this pull request may close these issues.

1 participant