← CodeClarityLab Home
Browse by Category
+ added · updated 7d
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Diagram: Discriminated Unions Discriminated Unions 2.0
A union of types that each carry a shared literal field (the discriminant) allowing TypeScript to narrow exhaustively — the canonical way to model mutually exclusive states.
4w ago typescript intermediate
Diagram: Type Guards & Narrowing Type Guards & Narrowing 2.0
Type guards are expressions that narrow a union type to a more specific type at runtime — telling TypeScript exactly which branch of a union you're in.
4w ago typescript intermediate
const Type Parameters (TS 5.0) 5.0
TypeScript 5.0 const type parameters infer literal types instead of widened types — const T extends string[] infers ['a','b'] not string[].
2mo ago typescript intermediate
Exhaustive Checks with never
Using the 'never' type in a default branch to make TypeScript error at compile time if a union type is not fully handled — ensures every new variant of a type forces a matching handler to be written.
2mo ago typescript intermediate
TypeScript Function Overloads
TypeScript function overloads allow a single function to accept different argument shapes and return different types based on which overload signature matches — providing precise type checking that union types alone cannot express.
2mo ago typescript intermediate
satisfies Operator (TS 4.9) 4.9
satisfies validates that a value matches a type without widening the inferred type — keeping precise literal types while checking against an interface.
2mo ago typescript intermediate
TypeScript Enums vs Const Enums vs Union Types 2.0
Three ways to define a set of named constants in TypeScript — regular enums emit JavaScript, const enums are inlined at compile time, and union types are the idiomatic zero-cost alternative.
2mo ago typescript intermediate
TypeScript Modules & Namespaces 2.0
ES modules (import/export) are the modern standard — namespaces are legacy for global scripts and ambient declarations only.
2mo ago typescript intermediate
TypeScript vs PHP Type System 4.0
TypeScript uses structural typing (shape compatibility); PHP uses nominal typing (explicit implements). TypeScript infers types; PHP requires annotations. Both support generics (PHP via PHPDoc).
2mo ago typescript intermediate
tsconfig.json 4.0
The TypeScript compiler configuration file — controlling which files are compiled, what JavaScript version is targeted, strictness settings, and module resolution.
2mo ago typescript intermediate
Diagram: TypeScript Interfaces vs Type Aliases TypeScript Interfaces vs Type Aliases 2.0
Both define object shapes, but interfaces are open (mergeable via declaration merging) while type aliases are closed — types are more flexible for unions and computed types.
2mo ago typescript intermediate
TypeScript Strict Mode 2.3
A tsconfig flag that enables the strictest type-checking options — strictNullChecks, noImplicitAny, and others — catching the most common TypeScript pitfalls.
2mo ago typescript intermediate
TypeScript Type System 2.0
TypeScript adds static types to JavaScript — catching type errors at compile time rather than runtime, while remaining a superset that compiles to plain JavaScript.
2mo ago typescript intermediate
Diagram: TypeScript Utility Types TypeScript Utility Types 2.1
Built-in generic types that transform existing types — Partial, Required, Pick, Omit, Record, Readonly, ReturnType — eliminating the need to manually duplicate type definitions.
2mo ago typescript intermediate
✓ schema.org compliant