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

Types exported from playwright-core, but not playwright #627

Closed
jperl opened this issue Jan 24, 2020 · 5 comments · Fixed by #628
Closed

Types exported from playwright-core, but not playwright #627

jperl opened this issue Jan 24, 2020 · 5 comments · Fixed by #628

Comments

@jperl
Copy link
Contributor

jperl commented Jan 24, 2020

// this works
import { ElementHandle } from "playwright-core";
// this does not
import { ElementHandle } from "playwright";
@jperl
Copy link
Contributor Author

jperl commented Jan 24, 2020

I am experiencing many type issues. Should I collect them all here and submit fixes in one PR, or open separate tickets and separate PRs?

Ex.

// types ok
await elementHandle.press("Backspace", undefined);

// not ok
await elementHandle.press("Backspace");

I believe

async press(key: string, options: { delay?: number; text?: string; } | undefined) {

should be

async press(key: string, options: { delay?: number; text?: string; } = {}) {

--

and

// works
import { DeviceDescriptor } from "playwright-core/lib/types";

// does not work
import { DeviceDescriptor } from "playwright-core";

@dgozman
Copy link
Contributor

dgozman commented Jan 24, 2020

Thanks @jperl! Collecting typing issues around specific methods is great, and any PRs are welcome. However, we plan to work on types soonish (probably hand-written .d.ts file), so general improvements like re-exporting types between packages will be probably lost during transition.

@jperl
Copy link
Contributor Author

jperl commented Jan 24, 2020

Thanks for your response. I will just keep collecting type issues here.

@jperl
Copy link
Contributor Author

jperl commented Jan 24, 2020

@dgozman Out of curiosity, what is the benefit of hand writing declaration files instead of exporting types directly from packages?

@dgozman
Copy link
Contributor

dgozman commented Jan 24, 2020

@dgozman Out of curiosity, what is the benefit of hand writing declaration files instead of exporting types directly from packages?

We can have different defaults externally vs internally (e.g. ElementHandle wrapping HTMLElement by default), have short documentation attached to be shown in IDEs, and not pollute types with internal methods starting with underscore.

sand4rt pushed a commit to sand4rt/playwright that referenced this issue Dec 21, 2022
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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

Successfully merging a pull request may close this issue.

2 participants