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

core(types): use union of puppeteer and puppeteer-core #14435

Merged
merged 2 commits into from
Oct 7, 2022

Conversation

adamraine
Copy link
Member

The types between these two packages are independent puppeteer/puppeteer#9018

If we want to support both, we should use the union between them to ensure proper type safety.

Some scripts import puppeteer themselves but use the types in LH.Puppeteer. These scripts should now be using the types from whatever puppeteer they pull in.

@adamraine adamraine requested a review from a team as a code owner October 6, 2022 19:19
@adamraine adamraine requested review from brendankenny and removed request for a team October 6, 2022 19:19
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

Ha, well I disagree with closing that issue (seems like that's exactly what puppeteer-core should be), but Lighthouse shouldn't be casting stones when it comes to what types should be exported by a project :)

This seems like it could cause problems down the line (parameters of unions of functions—and even worse, parameters of unions of functions that are callback parameters in unions of functions—often act unexpectedly), but I don't think there's a better solution right now, and we often have to cast things like pptr event listener callbacks anyway, so seems good for now.

types/puppeteer.d.ts Show resolved Hide resolved

/**
* @fileoverview Lighthouse should be compatible with puppeteer and puppeteer-core even though the types can be slightly different between the two packages.
* Anytime we want to use a Puppeteer type within Lighthouse, we should pull the union type from here rather than one of the packages directly.
Copy link
Member

Choose a reason for hiding this comment

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

this is probably a good candidate for pulling in as imported typedefs, but we can keep the global for now (someday it'll be ergonomic...)

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

Successfully merging this pull request may close these issues.

3 participants