Q&A
Playwright + TypeScript strict mode — how do you type Page Object Models properly?
Ajitesh MohantaAmbassador
2w ago 624 0
I'm building a Page Object Model layer with TypeScript strict mode enabled and running into issues typing things cleanly.
Specifically:
- `Locator` vs `Promise<Locator>` — I keep second-guessing which methods return which
- Typing constructor params when you need both `Page` and `BrowserContext`
- Whether to use `readonly` on locator properties or compute them lazily
Has anyone published a well-typed POM example I can reference? Or just share your base `BasePage` class if you're happy with it.