Skip to content

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