Skip to content

fix: support for off() & addListener() EventEmitter aliases #241

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

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/module-declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const generateModuleDeclaration = (
listener = `(${args.join(`,\n${indent}`)}) => void`;
}

for (let method of ['on', 'once', 'addListener', 'removeListener']) {
for (let method of ['on', 'off', 'once', 'addListener', 'removeListener']) {
moduleAPI.push(`${method}(event: '${moduleEvent.name}', listener: ${listener}): this;`);
}
});
Expand Down Expand Up @@ -251,7 +251,9 @@ export const generateModuleDeclaration = (
}

const returnsThis = (moduleMethod: Pick<DocumentationBlock, 'name'>) =>
['on', 'once', 'removeAllListeners', 'removeListener'].includes(moduleMethod.name);
['on', 'off', 'once', 'addListener', 'removeAllListeners', 'removeListener'].includes(
moduleMethod.name,
);

const addMethod = (moduleMethod: MethodDocumentationBlock, prefix = '') => {
utils.extendArray(
Expand Down