fix(types): allow any return type from event handlers (#30492)
Closes #29353.
This commit is contained in:
parent
b1d963c24c
commit
8fc7723f22
|
@ -7,8 +7,6 @@ test/assets/modernizr.js
|
|||
/packages/playwright-core/types/*
|
||||
/packages/playwright-ct-core/src/generated/*
|
||||
/index.d.ts
|
||||
utils/generate_types/overrides.d.ts
|
||||
utils/generate_types/test/test.ts
|
||||
node_modules/
|
||||
browser_patches/*/checkout/
|
||||
browser_patches/chromium/output/
|
||||
|
|
|
@ -290,9 +290,7 @@ Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` o
|
|||
**Usage**
|
||||
|
||||
```js
|
||||
page.on('dialog', dialog => {
|
||||
dialog.accept();
|
||||
});
|
||||
page.on('dialog', dialog => dialog.accept());
|
||||
```
|
||||
|
||||
```java
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,9 +43,7 @@ it('should allow accepting prompts @smoke', async ({ page, isElectron }) => {
|
|||
it('should dismiss the prompt', async ({ page, isElectron }) => {
|
||||
it.skip(isElectron, 'prompt() is not a thing in electron');
|
||||
|
||||
page.on('dialog', dialog => {
|
||||
void dialog.dismiss();
|
||||
});
|
||||
page.on('dialog', dialog => dialog.dismiss());
|
||||
const result = await page.evaluate(() => prompt('question?'));
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
|
|
|
@ -283,7 +283,7 @@ class TypesGenerator {
|
|||
parts.push(this.writeComment(comment, indent));
|
||||
else
|
||||
parts.push(this.writeComment(commentForMethod[method], indent));
|
||||
parts.push(` ${method}(event: '${eventName}', listener: (${params}) => void): this;\n`);
|
||||
parts.push(` ${method}(event: '${eventName}', listener: (${params}) => any): this;\n`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -921,6 +921,10 @@ playwright.chromium.launch().then(async browser => {
|
|||
.removeListener('close', listener)
|
||||
.off('close', listener);
|
||||
}
|
||||
{
|
||||
const page: playwright.Page = {} as any;
|
||||
page.on('dialog', dialog => dialog.accept());
|
||||
}
|
||||
});
|
||||
|
||||
// waitForResponse callback predicate
|
||||
|
|
Loading…
Reference in New Issue