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: fix exported types #7742
fix: fix exported types #7742
Conversation
5609147
to
ad5ef2a
Compare
ad5ef2a
to
752362e
Compare
Interesting. It seems that the export of the instance should be kind of @jschfflr could you please help with that? |
@whimboo @connorjclark @jackfranklin @OrKoN maybe you can help with ^^ please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the PR. Do you know if this will have any impact on CommonJS consumers? Do you see a way to fix the types without breaking changes for the consumers? Could you please rebase so that we can run CI?
You cannot export functions if actually you export a class (methods of a class != separate functions) Issues: #7529 BREAKING CHANGE: to use `launch` method (and any other methods from Puppeteer class) now you have to import `puppeteer` via import default export, i.e. `import puppeteer from 'puppeteer'`
752362e
to
db4a695
Compare
Done (but tbh I didn't check it locally since I was on a windows pc right now and it might just fail because of that).
I didn't see any way to do this. The types are incorrect and should be fixed so it would be a breaking change anyway.
Well, I think this is quite similar to what I asked in #7742 (comment) because I'm not too sure how it works internally. |
Thanks! I was under impression that src/api-docs-entry.ts is only used for the documentation generation so should not actually be shipped (at least there are comments indicating that). I will double check next week. I think comment https://github.com/puppeteer/puppeteer/blob/main/cjs-entry.js#L18 and cjs-entry.js might be causing the issue. |
@OrKoN have you had a chance to double check it? 🙂 |
@timocov sorry, I have not managed yet. But it looks like the PR is failing CI checks anyway? |
@OrKoN that's true, but to fix them we need to answer questions from #7742 (comment) I believe. It looks like a problem is still here, but it just works in some cases and no one mentioned it before. Probably it might be solved by using exports map (and provide different types files for different type of importing a package, but I'm not sure if tsc supports it yet. ¯_(ツ)_/¯ |
Reaching back to when I did the work to setup this build, I think this is because when we first released the types we had issues where it did work for CJS users, or ESM users, but not both. So this test suite exists to ensure that our type configuration supports all users and their setups. Long term I'd like to drop CJS and move to ESM, but that's a separate discussion. RE api-docs-entry.ts, I think that should only be used by the code that takes all the TSDoc comments and generates the docs, and not as part of the main types that are used by the compiler when checking the code. But I'm reaching back to work that was done 12 months ago and it's not the most fresh in my memory, so I'd need to dig into the setup to remind myself. |
This does not seem relevant anymore. A workaround is to use Closing this as this PR is stale. |
I think we still need to address that so that the types match the documentation. |
@OrKoN Wouldn't this affect people who already import using |
yeah, it would be a breaking change. I think we need to do the following:
|
Closed in favor of #8493 |
What kind of change does this PR introduce? bugfix
Did you add tests for your changes? No
If relevant, did you update the documentation? Not relevant
Summary
You cannot export functions if actually you export a class (methods of a class != separate functions).
Fixes #7529
Does this PR introduce a breaking change?
To use
launch
method (and any other methods from Puppeteer class) now you have to importpuppeteer
via import default export, i.e.import puppeteer from 'puppeteer'
.Other information