TypeScript Type System & Annotations. TypeScript extends JavaScript by adding static type definitions. Types provide a way to describe the shape of objects, enabling better documentation and error detection.. Basic Types…
ReadTypeScript Interview Questions. Comprehensive TypeScript interview questions covering type system, generics, utility types, and best practices:. Fundamentals. 1. What is TypeScript?. TypeScript is a typed superset of Jav…
ReadTypeScript Advanced Types. Generics. // Generic function function identity<T>(arg: T): T { return arg; } const num = identity<number>(42); // Explicit const str = identity('hello'); // Inferred // Generic with constraint…
ReadTypeScript Decorators & Metadata. Decorators provide a way to add annotations and meta-programming syntax for class declarations and members. They are functions that modify classes and their members.. Class Decorators. /…
ReadTypeScript Configuration & Best Practices. tsconfig.json Essentials. { "compilerOptions": { // Language version "target": "ES2022", "lib": ["ES2022", "DOM"], // Module system "module": "ESNext", "moduleResolution": "bund…
ReadTypeScript Type Guards & Narrowing. Type Narrowing. // typeof narrowing function padLeft(value: string, padding: string | number) { if (typeof padding === 'number') { return ' '.repeat(padding) + value; } return padding …
ReadTypeScript Advanced Patterns. Conditional Types. // Basic conditional type type IsString<T> = T extends string ? true : false; type A = IsString<string>; // true type B = IsString<number>; // false // Practical example t…
ReadTypeScript Enums & Literal Types. Enums. Enums allow you to define a set of named constants, making it easier to document intent and create distinct cases.. // Numeric enum enum Direction { Up, // 0 Down, // 1 Left, // 2…
ReadSave this stack to your personal DevRecall — add your own notes, track what you're learning, and share what you know with the community.
Get started — free forever