Skip to main content
Q&A

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

Ajitesh Mohanta
Ajitesh MohantaAmbassador
May 25, 2026 924 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 comments yet. Be the first to answer this question!

Join the discussion

Have something to add?

Sign in to reply, follow this thread, and earn XP when your answer helps someone.

Playwright + TypeScript strict mode — how do you type Page Object Models properly? — QA Bash Community | QA Bash