Day 59 of 100: satisfies — Typed Configs Without Widening
Day 59 of 100 — 100 Days of Playwright with TypeScript Challenge. Phase: TypeScript. JavaScript (Days 1-33) → TypeScript (Days 34-63) → Playwright (Days 64-96) → AI Framework Capstone (Days 97-100).
🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.
satisfies validates a value against a type WITHOUT widening it. The config-file operator you did not know you needed.
Contents
The Problem It Solves
type Config = { baseUrl: string; retries: number; tags: string[] };
// Annotation widens — literal info lost:
const c1: Config = { baseUrl: 'http://localhost', retries: 2, tags: ['smoke'] };
// c1.baseUrl: string (just string)
// satisfies checks AND keeps literals:
const c2 = {
baseUrl: 'http://localhost',
retries: 2,
tags: ['smoke'],
} satisfies Config;
// c2.baseUrl: 'http://localhost' — literal preserved
// typo a key or wrong type → still a compile error
🚀 Level Up Your Playwright
From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.
Env Map, Both Guarantees
type Env = 'local' | 'staging' | 'prod';
const URLS = {
local: 'http://localhost:3000',
staging: 'https://staging.example.com',
prod: 'https://example.com',
} satisfies Record;
// 1) Missing/extra env key → error (Record check)
// 2) URLS.local is the literal 'http://localhost:3000' (no widening)
type LocalUrl = typeof URLS.local; // 'http://localhost:3000'
Where It Belongs in a Test Repo
- playwright.config.ts option objects — validated, autocomplete-rich
- Env/url/credential maps — exhaustive AND literal
- Test data templates checked against payload types without losing specificity
Tomorrow (Day 60): TS capstone — the typed API client.
🎓 Master Playwright End to End
Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.
