Skip to main content
Community
Q&A

Playwright + TypeScript strict mode — how do you type Page Object Models properly?

Ajitesh Mohanta
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.

No replies yet. Be the first to answer this question!

Join the discussion

Sign in to join the discussion

Sign in