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

Provide .d.ts from puppeteer NPM package #5857

Closed
Quramy opened this issue May 13, 2020 · 11 comments
Closed

Provide .d.ts from puppeteer NPM package #5857

Quramy opened this issue May 13, 2020 · 11 comments
Assignees

Comments

@Quramy
Copy link
Contributor

Quramy commented May 13, 2020

It seems that you're migrating to TypeScript and almost all sources have been migrated. Do you have any plan to provide .d.ts files from Puppeteer NPM package (not @types/puppeteer )?

@mathiasbynens
Copy link
Member

This was indeed one of the goals of the TypeScript migration. We're not quite there yet though.

@jackfranklin
Copy link
Collaborator

jackfranklin commented May 13, 2020

Yup, we will eventually. Right now @types/puppeteer has a more comprehensive set of types for things like $eval and evaluateHandle that we'll like to pull into Puppeteer. I've chatted with @marvinhagemeister (who helped write the DefinitelyTyped definitions) about this and it's on my list.

@marvinhagemeister
Copy link
Contributor

yup, I'd love if puppeteer came with types straight out of the box. That'd be a much smoother experience for users 👍

@Pyppe
Copy link

Pyppe commented Jun 16, 2020

Now that 4.0.0 is out, it would be great if this worked out of the box:

error TS7016: Could not find a declaration file for module 'puppeteer'. 'puppeteer-web-server/node_modules/puppeteer/index.js' implicitly has an 'any' type.
  Try `npm install @types/puppeteer` if it exists or add a new declaration (.d.ts) file containing `declare module 'puppeteer';`

2 import { Browser, Page, Viewport } from 'puppeteer'
                                                  ~~~~~~~~~~~

I believe the type declarations are missing from node_modules/puppeteer/index.js when using puppeteer@4.0.0.

@jackfranklin
Copy link
Collaborator

The reason we haven't shipped types out of the box yet (or configured them) is because I think the types from the DefinitelyTyped repo are superior, so I don't want people to have a less-good experience. Especially the way the @types package defines all the $eval type functions is much better and gives much better errors. It's on my list to explore how best to pull those into our codebase - it's also something I'd welcome help with and be happy to pair on if anyone is interested.

We could ship our types but only if then installing @types/puppeteer overrides them, which I'm not sure about. I'd welcome thoughts and suggestions here so please shout if you have them :)

@Pyppe
Copy link

Pyppe commented Jun 16, 2020

Is there then going to be DefinitelyTyped for version 4.0 also? It seems, currently 3.0 is the latest: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/puppeteer/index.d.ts

For the time being, having neither (DefinitelyTyped nor index.d.ts) makes upgrading quite difficult (we wouldn't want to resort to temporary hacks)

@Pyppe
Copy link

Pyppe commented Jul 3, 2020

Hi there! Still would like to hear what is currently the upgrade path to 4.0 using Typescript? If there's neither out-of-the-box types nor DefinitelyTyped types, how should one get the setup working?

@jackfranklin
Copy link
Collaborator

Hey @Pyppe I'm afraid you may have to manually define the types yourself. Not much changed from 3 to 4 besides the event emitter; you could always take the existing DefinitelyTyped types as your starting point?

I appreciate that's non ideal but our focus is on shipping a version in the not-too-distant future that does provide types out the box so we're focusing on that rather than types for v4.

You can track the progress of that in #6124 .

I know @jsoverson was playing with our typedefs, so he might know a way of getting types + Puppeteer v4/5 working until we ship typedefs for real?

@jsoverson
Copy link
Contributor

@Pyppe I have one decent-sized project and multiple smaller ones ported to puppeteer 4.0. My projects directly benefited from the aligned types so I worked through it. I wouldn't recommend porting yet unless there is a compelling reason.

Major version upgrades like these don't signify a swath of new, exciting features, just that there are breaking changes.

@stale
Copy link

stale bot commented Jun 26, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 26, 2022
@stale
Copy link

stale bot commented Jul 26, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

@stale stale bot closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants