TypeScript for SDETs

MODULE 1 OF 8 β€’ THEORY

1. Basic Type Annotations

basic

TypeScript enforces static type parameters (string, number, boolean, arrays). Annotating variables catches typo mismatches at compilation before executing commands in browsers.

Syntax Template
const timeoutMs: number = 10000;
const pageTitle: string = "Dashboard";
When to use

Use type annotations for complex configs, helper inputs, or global state parameters to guarantee correct variables are supplied.

Best practice

Always avoid the "any" type because it disables TypeScript checks. Prefer "unknown" if a server response is dynamic, and narrow it down later.

TypeScript Compiler & Output
v5.0.4
[tsc] Ready to type check ts-types.ts...
[Node.js] Click "Run Code" to compile and run.