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-core/types/*
|
||||||
/packages/playwright-ct-core/src/generated/*
|
/packages/playwright-ct-core/src/generated/*
|
||||||
/index.d.ts
|
/index.d.ts
|
||||||
utils/generate_types/overrides.d.ts
|
|
||||||
utils/generate_types/test/test.ts
|
|
||||||
node_modules/
|
node_modules/
|
||||||
browser_patches/*/checkout/
|
browser_patches/*/checkout/
|
||||||
browser_patches/chromium/output/
|
browser_patches/chromium/output/
|
||||||
|
|
|
||||||
|
|
@ -290,9 +290,7 @@ Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` o
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
```js
|
```js
|
||||||
page.on('dialog', dialog => {
|
page.on('dialog', dialog => dialog.accept());
|
||||||
dialog.accept();
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|
|
||||||
556
packages/playwright-core/types/types.d.ts
vendored
556
packages/playwright-core/types/types.d.ts
vendored
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('should dismiss the prompt', async ({ page, isElectron }) => {
|
||||||
it.skip(isElectron, 'prompt() is not a thing in electron');
|
it.skip(isElectron, 'prompt() is not a thing in electron');
|
||||||
|
|
||||||
page.on('dialog', dialog => {
|
page.on('dialog', dialog => dialog.dismiss());
|
||||||
void dialog.dismiss();
|
|
||||||
});
|
|
||||||
const result = await page.evaluate(() => prompt('question?'));
|
const result = await page.evaluate(() => prompt('question?'));
|
||||||
expect(result).toBe(null);
|
expect(result).toBe(null);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ class TypesGenerator {
|
||||||
parts.push(this.writeComment(comment, indent));
|
parts.push(this.writeComment(comment, indent));
|
||||||
else
|
else
|
||||||
parts.push(this.writeComment(commentForMethod[method], indent));
|
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)
|
.removeListener('close', listener)
|
||||||
.off('close', listener);
|
.off('close', listener);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const page: playwright.Page = {} as any;
|
||||||
|
page.on('dialog', dialog => dialog.accept());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// waitForResponse callback predicate
|
// waitForResponse callback predicate
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue