// this works
import { ElementHandle } from "playwright-core";
// this does not
import { ElementHandle } from "playwright";
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";
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.
Thanks for your response. I will just keep collecting type issues here.
@dgozman Out of curiosity, what is the benefit of hand writing declaration files instead of exporting types directly from packages?
@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.
Most helpful comment
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.tsfile), so general improvements like re-exporting types between packages will be probably lost during transition.