TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
TypeScript / Chapter 24 of 60~12 min • Beginner
Chapter 24TypeScript

Interfaces and type aliases

Interfaces describe object shapes. Type aliases can name object types, unions and other types. Both can describe the fields a test data record requires. They are erased from emitted JavaScript.

How it works

Step-by-step walkthrough

  1. Define a user interface
  2. Create a matching record
  3. Read its fields

Example

TypeScript
interface User {
  name: string;
  active: boolean;
}
const user: User = { name: 'QA', active: true };
console.log(user.name);
Expected result: QA
💡 Point to remember
Interfaces do not validate JSON at runtime.

✎ Your practice task

Omit active and observe the type checker.

Knowledge check

Which property must a User object contain here?

🌐 Continue learning