Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
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 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 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.
TypeScript Arrow Functions with Generics: Syntax and Examples
Learn the syntax for generic arrow functions in TypeScript with clear examples, pitfalls, and practical usage in real code.
TypeScript Constructor Overloading: How to Use Overload Signatures Correctly
Learn how constructor overloading works in TypeScript using overload signatures and a single implementation with clear examples.
TypeScript Getters and Setters: How to Use get and set Correctly
Learn how getters and setters work in TypeScript, including syntax, examples, common mistakes, and how to define property accessors correctly.
TypeScript Index Signatures vs Mapped Types with Enums
Learn why TypeScript index signatures cannot use enum unions and how to fix it with mapped types and Record objects.
TypeScript Indexed Access Types: Get a Value Type from a Key
Learn how to get a property value type from a key in TypeScript using generics and indexed access types like T[K].
TypeScript Non-Null Assertion Operator (!) Explained
Learn what the TypeScript non-null assertion operator (!) does, how it works, when to use it, and safer alternatives with examples.
TypeScript unknown vs any: Differences, Safety, and When to Use Each
Learn the difference between TypeScript unknown and any, when to use each, and how unknown improves type safety in real code.