Skip to content

Commit

Permalink
Make Emittery.mixin type support arguments in constructor
Browse files Browse the repository at this point in the history
Fixes #79
Closes #101
  • Loading branch information
sindresorhus committed Aug 8, 2022
1 parent e0b4ba7 commit 32ddcbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ declare class Emittery<
static mixin(
emitteryPropertyName: string | symbol,
methodNames?: readonly string[]
): <T extends {new (): any}>(klass: T) => T; // eslint-disable-line @typescript-eslint/prefer-function-type
): <T extends {new (...arguments_: any[]): any}>(klass: T) => T; // eslint-disable-line @typescript-eslint/prefer-function-type

/**
Subscribe to one or more events.
Expand Down
5 changes: 5 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,8 @@ type AnyListener = (eventData?: unknown) => void | Promise<void>;
Emittery.mixin('emittery')(class {
test() {}
});

// Mixin type - arguments in constructor
Emittery.mixin('emittery')(class { // eslint-disable-line @typescript-eslint/no-extraneous-class
constructor(argument: string) {} // eslint-disable-line @typescript-eslint/no-useless-constructor
});

0 comments on commit 32ddcbe

Please sign in to comment.