mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: type page event listeners correctly (#6891)
This PR fixes the fact that currently if you have:
```ts
page.on('request', request => {
})
```
Then `request` will be typed as `any`. We can fix this by defining an
interface of event name => callback argument type, and looking that up
when you call `page.on`.
Also includes a drive-by fix to ensure we convert response headers to
strings, and updates the types accordingly.
This commit is contained in:
@@ -864,6 +864,27 @@ function compareDocumentations(actual, expected) {
|
||||
expectedName: 'Array<Permission>',
|
||||
},
|
||||
],
|
||||
[
|
||||
'Method HTTPRequest.respond() response.body',
|
||||
{
|
||||
actualName: 'string|Buffer',
|
||||
expectedName: 'Object',
|
||||
},
|
||||
],
|
||||
[
|
||||
'Method HTTPRequest.respond() response.contentType',
|
||||
{
|
||||
actualName: 'string',
|
||||
expectedName: 'Object',
|
||||
},
|
||||
],
|
||||
[
|
||||
'Method HTTPRequest.respond() response.status',
|
||||
{
|
||||
actualName: 'number',
|
||||
expectedName: 'Object',
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
const expectedForSource = expectedNamingMismatches.get(source);
|
||||
|
||||
Reference in New Issue
Block a user