Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
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.
How to Watch and Reload ts-node When TypeScript Files Change
Learn how to watch TypeScript files and automatically restart a ts-node dev server using practical tools and examples.
Interfaces vs Type Aliases in TypeScript
Learn the difference between interface and type in TypeScript, when to use each, and how they behave in real codebases.
JSX.Element vs ReactNode vs ReactElement in React TypeScript
Learn the difference between JSX.Element, ReactNode, and ReactElement in React TypeScript, including null returns and component typing.
Optional Chaining in TypeScript: Does TypeScript Support `?.` and What Is It Called?
Learn whether TypeScript supports the `?.` operator, what it is called, how it works, and how to use optional chaining safely in TypeScript.
Runtime Interface Type Checks in TypeScript: Why `instanceof` Does Not Work
Learn why TypeScript interfaces do not exist at runtime, why `instanceof` fails, and how to safely check object shapes instead.
Runtime Type Checks in TypeScript: Classes, Interfaces, instanceof, and Type Guards
Learn how runtime type checks work in TypeScript using instanceof, type guards, and why interfaces cannot be checked directly.
String vs string in TypeScript: Primitive vs Wrapper Object
Learn the difference between string and String in TypeScript, why assignment fails, and when to use the primitive type instead.
Strongly Typed Function Parameters in TypeScript
Learn how to type callback function parameters in TypeScript using function signatures instead of Function for safer code.
Subject vs BehaviorSubject in RxJS: What’s the Difference?
Learn the difference between Subject and BehaviorSubject in RxJS, including current value behavior, subscriptions, and real examples.