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

puppeteer.HTTPRequest resourceType() returns string instead of a resource type enum #6854

Closed
davidbielik opened this issue Feb 10, 2021 · 1 comment · Fixed by #6882, #6891, juicyfx/juicy#697 or concourse/concourse#6685 · May be fixed by TheDogenode/torrent-aio-bot#6

Comments

@davidbielik
Copy link

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 7.0.4
  • Platform / OS version: Mac
  • URLs (if applicable): n/a
  • Node.js version: v10

I want to ask about difference while migrating from @types/puppeteer to the included definitions (thank you btw!)

In the past (with DefinitelyTyped), request resource types were defined ("document", "xhr", etc.):

page.on("request", request => {
   const resourceType = request.resourceType(); // puppeteer.ResourceType
});

Now, it returns string. I see there is a puppeteer.Protocol.Network.ResourceType (although those are not lowercased).

Is there a type we can use for this instead of string? Same for request.method() which also now returns string instead of the old DefinitelyTyped puppeteer.HttpMethod.

Thank you!

@jackfranklin
Copy link
Collaborator

Thanks! Marking as closed as #6882 will resolve this which will be in the next release.

jackfranklin added a commit that referenced this issue Feb 16, 2021
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.
jschfflr pushed a commit that referenced this issue Feb 17, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment