Day 35 of 100: Basic Types — Annotations and Inference
Day 35 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.
Annotate variables, parameters, and returns. The compiler enforces the rest.
Contents
Annotations
const name: string = 'Playwright';
const retries: number = 2;
const headless: boolean = true;
const browsers: string[] = ['chromium', 'firefox'];
const codes: Array = [200, 201, 204]; // same as number[]
function buildUrl(path: string): string {
return 'http://localhost:3000' + path;
}
// buildUrl(42) — error: number not assignable to string
// const x: string = 5 — error caught instantly
🚀 Level Up Your Playwright
From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.
Inference — Let TS Work
const env = 'staging'; // inferred as string (actually 'staging' literal)
const timeout = 30_000; // inferred number
const tags = ['smoke', 'ui']; // inferred string[]
// Rule: annotate function signatures and empty containers;
// let inference handle initialized locals.
const failures: string[] = []; // empty array NEEDS annotation
Tomorrow (Day 36): Objects and type aliases — typing test data.
🎓 Master Playwright End to End
Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.
