Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Handle Optional Parameters in TypeScript When Skipping Earlier Arguments
Learn how optional parameters work in TypeScript and how to pass later values when skipping earlier optional arguments.
How to Handle TS2533: Object Is Possibly 'null' or 'undefined' in TypeScript
Learn why TypeScript shows TS2533 for possibly null or undefined values and how to fix it safely with checks, assertions, and better types.
How to Ignore TypeScript Errors: @ts-ignore, File-Level Alternatives, and Safer Patterns
Learn how @ts-ignore works in TypeScript, why it only affects one line, and the safe alternatives for larger code blocks or files.
How to Import JSON in TypeScript and Use Typed Properties
Learn how to import JSON files in TypeScript, why property errors happen, and how to fix JSON imports in TS and TSX files correctly.
How to Import SVG Files in TypeScript and TSX
Learn why TypeScript cannot import SVG files by default and how to fix it in TSX with module declarations and practical examples.
How to Iterate Over Object Keys and Values with *ngFor in Angular
Learn how to loop through object keys and values in Angular using *ngFor and the keyvalue pipe, with examples and common mistakes.
How to Loop Through Enum Values in TypeScript
Learn how TypeScript enums work and how to loop through enum values without getting reverse-mapped numeric keys.
How to Parse a JSON String in TypeScript
Learn how to parse JSON strings in TypeScript with JSON.parse(), type the result safely, validate unknown data, and handle invalid JSON.
How to Pass Data to Angular Routed Components
Learn practical ways to pass data to Angular routed components using route params, query params, navigation state, and shared services.
How to Reject a Promise in async/await with TypeScript
Learn how to reject promises correctly in async/await TypeScript code using throw, try/catch, and proper error handling patterns.
How to Remove an Array Item in TypeScript
Learn how to remove an item from a TypeScript array by key using findIndex, filter, and splice with clear examples and common mistakes.
How to Run TypeScript Files from the Command Line
Learn how to run TypeScript files from the command line using tsc, ts-node, and Node.js with practical examples and common pitfalls.
How to Select an Element in an Angular Component Template
Learn how to access template elements in Angular using template reference variables, @ViewChild, and ElementRef with clear examples.
How to Set Default Values for Object Parameters in TypeScript
Learn how to set default values for object parameters in TypeScript using destructuring, optional properties, and safe fallback patterns.
How to Type Dates in TypeScript
Learn the correct way to type dates in TypeScript, when to use Date, and how it differs from strings and timestamps.
How to Type Function Callbacks in TypeScript Interfaces
Learn how to define callback function types in TypeScript interfaces using proper function signatures instead of any.
How to Type Object Literal Properties in TypeScript
Learn how to declare types for object literal properties in TypeScript, why `property: string` fails, and the correct syntax to use.
How to Type an Array of Objects in TypeScript
Learn how to declare and type an array of objects in TypeScript, with inline types, interfaces, and safe property access examples.
How to Type the children Prop in React with TypeScript
Learn how to type the React children prop in TypeScript, why ReactNode can cause JSX errors, and how to fix functional components correctly.
How to Use async/await with Array.map in TypeScript
Learn why Array.map with async returns Promise[] in TypeScript and how to fix it using Promise.all with clear examples.