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

[BUG] No Playwright class typed definition anymore in @next #1483

Closed
mxschmitt opened this issue Mar 23, 2020 · 6 comments
Closed

[BUG] No Playwright class typed definition anymore in @next #1483

mxschmitt opened this issue Mar 23, 2020 · 6 comments

Comments

@mxschmitt
Copy link
Member

Context:

  • Playwright Version: 0.11.1-next.1584947279674 (March 23, 2020)
  • Operating System: Linux

Code Snippet

import { Playwright } from 'playwright-core/lib/server/playwright'

const pw = new Playwright({
  browsers: ['webkit', 'chromium', 'firefox'],
});

Describe the bug

In version 0.11.1 and some of the recent next releases it was working. Now the types are missing.

Version 0.11.1 example: https://unpkg.com/playwright-core@0.11.1/lib/server/playwright.d.ts

I think it's related to #1166.

cc @JoelEinbinder

@JoelEinbinder
Copy link
Contributor

This is working as intended. The Playwright constructor is not part of the public api. What is your use case?

@mxschmitt
Copy link
Member Author

mxschmitt commented Mar 23, 2020

https://github.com/mxschmitt/try-playwright/blob/6b112eec4b2fdd2e831b9bf7d3052ecf6119bb55/backend/src/playwright.ts#L86-L101

Hmm, yep its a kinda hacky approach to overwrite the methods.

So the use case in a nutshell is to overwrite the launch methods dynamically and assign to their browsers an ID.

Edit: Another use case is on Try Playwright for that the usage in the Monaco editor. there I also just have used the previous class Playwright as a playwright interface.

Also I found a issue in playwright-video: https://github.com/qawolf/playwright-video/blob/9a7912f6fb04aa86ff5c4be757ef5dccfddd0dcb/src/ScreencastFrameCollector.ts#L4 that the type could not be resolved.

@jperl
Copy link
Contributor

jperl commented Mar 23, 2020

Is it possible for playwright-core to expose the types for power users so we don't have to manually define our own declaration files?

@JoelEinbinder
Copy link
Contributor

Is it possible for playwright-core to expose the types for power users so we don't have to manually define our own declaration files?

I really don't want to support people hacking on our internal code. I'd much rather support your use cases in the public api.

@JoelEinbinder
Copy link
Contributor

https://github.com/mxschmitt/try-playwright/blob/6b112eec4b2fdd2e831b9bf7d3052ecf6119bb55/backend/src/playwright.ts#L86-L101

Hmm, yep its a kinda hacky approach to overwrite the methods.

The main issue here is that you want multiple playwright objects in the same node process, with their own prototype hacks on it. If you are ok with the same hacks everywhere, then requiring playwright-core directly will work. I don't think this will ever work cleanly though.

Edit: Another use case is on Try Playwright for that the usage in the Monaco editor. there I also just have used the previous class Playwright as a playwright interface.

Instead try typeof import('playwright-core').

Also I found a issue in playwright-video: https://github.com/qawolf/playwright-video/blob/9a7912f6fb04aa86ff5c4be757ef5dccfddd0dcb/src/ScreencastFrameCollector.ts#L4 that the type could not be resolved.

This just needs to use the CDPSession type from the root of playwright instead.

Closing this issue for now as I consider it not a bug. Feel free to keep up the discussion here about internal types, or file new issues for specific things that might be missing/broken.

@jperl
Copy link
Contributor

jperl commented Mar 23, 2020

This makes sense, I have not had a chance to use the new types yet. I will open an issue for any missing types in the public API.

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

No branches or pull requests

3 participants