mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(types): add better descriptions for event emitter methods (#6417)
This commit is contained in:
parent
ae489b1c43
commit
e4698b5f6a
633
types/types.d.ts
vendored
633
types/types.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -220,10 +220,17 @@ function createEventDescriptions(classDesc) {
|
||||
function classBody(classDesc) {
|
||||
const parts = [];
|
||||
const eventDescriptions = createEventDescriptions(classDesc);
|
||||
const commentForMethod = {
|
||||
off: 'Removes and event listener added by `on` or `addListener`',
|
||||
removeListener: 'Removes and event listener added by `on` or `addListener`',
|
||||
once: 'Adds an event listener that will be automatically removed after it is triggered once. See `addListener` for more information about this event.'
|
||||
}
|
||||
for (const method of ['on', 'once', 'addListener', 'removeListener', 'off']) {
|
||||
for (const {eventName, params, comment} of eventDescriptions) {
|
||||
if (comment)
|
||||
if ((method === 'on' || method === 'addListener') && comment)
|
||||
parts.push(writeComment(comment, ' '));
|
||||
else
|
||||
parts.push(writeComment(commentForMethod[method], ' '));
|
||||
parts.push(` ${method}(event: '${eventName}', listener: (${params}) => void): this;\n`);
|
||||
}
|
||||
}
|
||||
@ -434,4 +441,4 @@ function renderJSSignature(args) {
|
||||
if (hasOptional)
|
||||
tokens.push(']');
|
||||
return tokens.join('');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user