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:
Jack Franklin
2021-03-25 11:26:35 +00:00
committed by GitHub
parent e31e68dfa1
commit 866d34ee11
4 changed files with 82 additions and 3 deletions

View File

@@ -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);