Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: explicit HTTPRequest.resourceType type defs #6882

Merged
merged 1 commit into from Feb 17, 2021

Conversation

jackfranklin
Copy link
Collaborator

Fixes #6854.

*
* @public
*/
export type ResourceType =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my local browser_protocol.pdl file, there are some more ResourceTypes:

  • SignedExchange
  • Ping
  • CSPViolationReport
  • Preflight

Is there a specific reason why they are not included here?

We can use the new `Lowercase` util in TS4 to avoid duplicating the type
and instead lowercase it.

Note we still need to do the work so callbacks are typed correctly:

```ts
page.on('request', request => {

})
```

Right now `request` is `any`, whereas it should be a
`puppeteer.HTTPRequest`. You can manually set the type for now, and I
will work on adding types for events so that this is done automatically
by the compiler in a future release.

Fixes #6854.
@jackfranklin
Copy link
Collaborator Author

@jschfflr please take another look - I discovered the Lowercase util so we don't have to duplicate the list :)

Copy link
Contributor

@jschfflr jschfflr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

puppeteer.HTTPRequest resourceType() returns string instead of a resource type enum
2 participants