Skip to content

Regresssion in PR#96 #97

@thetutlage

Description

@thetutlage

The #96 introduces a regression when emittery is used as a sub-class. Lemme share a code sample.

const Emittery = require("emittery");

class MyEmitter extends Emittery {
  async emit(eventName, data) {
  	return super.emit(eventName, data)
  }
}

new MyEmitter().on('foo', () => {})

Adding a listener foo will raise an exception from this line https://github.com/sindresorhus/emittery/blob/main/index.js#L262, since it is calling this.emit with three arguments.

Now, I can update the emit method on my class to accept the 3rd argument and pass it to super.emit. However, then TypeScript complains that the emit method takes only two arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions