Programming Exercises
Practice with real problems and instant feedback.
Typed Promise.all
Use Promise.all with proper TypeScript typing to run multiple async operations in parallel and collect typed results.
Readonly Array Types
Use TypeScript readonly array types to prevent mutation of array parameters in functions.
Record Type for Maps
Use the Record utility type to create type-safe map objects with specific key and value types.
Recursive Type Definitions
Define a recursive TypeScript type for a tree structure and write a function to traverse it depth-first.
Result Type for Error Handling
Implement a Result type for explicit error handling without exceptions in TypeScript.
Template Literal Types
Use TypeScript template literal types to create type-safe string patterns for HTTP method and path combinations.
Template Literal Type Inference
Use infer in template literal types to extract parts of type-safe string patterns at the type level.
Advanced Template Literal Types
Use template literal types to create type-safe event names and CSS property selectors with string interpolation.
Tuple Type Operations
Use TypeScript tuple types to represent fixed-length arrays with specific element types at each position.
Type Assertion Safety
Use TypeScript type assertions to narrow an unknown value to a specific type with runtime validation.
Custom Type Guard Functions
Write custom type guard functions using the is operator to narrow unknown data to specific types at runtime.
Custom Type Guards
Write custom type guard functions to narrow union types at runtime in TypeScript.
Union Type Handling
Use TypeScript union types to handle values that can be one of several types, with proper type narrowing.
Custom Utility Types
Create custom utility types for deep partial, deep readonly, and path-based property access.
Variance in Generic Types
Explore TypeScript variance rules with covariant arrays and contravariant function parameters.