fix(types): add missing types for removing event listeners (#2307)
This commit is contained in:
parent
e558f0516b
commit
8e396fdac0
|
|
@ -159,7 +159,7 @@ function createEventDescriptions(classDesc) {
|
|||
function classBody(classDesc) {
|
||||
const parts = [];
|
||||
const eventDescriptions = createEventDescriptions(classDesc);
|
||||
for (const method of ['on', 'once', 'addListener']) {
|
||||
for (const method of ['on', 'once', 'addListener', 'removeListener', 'off']) {
|
||||
for (const {eventName, params, comment} of eventDescriptions) {
|
||||
if (comment)
|
||||
parts.push(writeComment(comment, ' '));
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ playwright.chromium.launch().then(async browser => {
|
|||
|
||||
import * as crypto from 'crypto';
|
||||
import * as fs from 'fs';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
playwright.chromium.launch().then(async browser => {
|
||||
const page = await browser.newPage();
|
||||
|
|
@ -729,3 +730,14 @@ playwright.chromium.launch().then(async browser => {
|
|||
// Register the engine. Selectors will be prefixed with "tag=".
|
||||
await playwright.selectors.register('tag', createTagNameEngine);
|
||||
})();
|
||||
|
||||
// Event listeners
|
||||
(async function() {
|
||||
const eventEmitter = {} as (playwright.Page|playwright.BrowserContext|EventEmitter);
|
||||
const listener = () => {};
|
||||
eventEmitter.addListener('close', listener)
|
||||
.on('close', listener)
|
||||
.once('close', listener)
|
||||
.removeListener('close', listener)
|
||||
.off('close', listener);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue