Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
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 Dictionary Initialization and Structural Type Checking Explained
Learn why a TypeScript dictionary may accept invalid-looking values and how structural type checking works with object literals.
TypeScript Dictionary Objects: How to Type Key-Value Objects
Learn how to type dictionary-style objects in TypeScript using index signatures, Record, and when to use objects vs arrays.
TypeScript Function Overloading Explained
Learn how TypeScript function overloading works, why duplicate identifier errors happen, and how to write correct overloads with 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 Interface Default Values and Optional Properties
Learn why TypeScript interfaces cannot set runtime defaults, how optional properties work, and safer patterns for initializing objects later.
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 Object Indexing with String Keys and keyof
Learn why TypeScript rejects string object indexing and how to safely use keyof, Record, and type guards for dynamic keys.
TypeScript Optional Parameters: What Does the Question Mark Mean?
Learn what the question mark means in TypeScript parameters, how optional values work, and how to safely use defaults in constructors.
TypeScript String Enums: Create Enums with String Values
Learn how to create TypeScript string enums, access their values, validate inputs, and avoid common enum mistakes with practical examples.
TypeScript String Literal Union Types in Interfaces
Learn how to restrict an interface property to specific string values with TypeScript string literal union types and practical examples.
TypeScript Types in Object Destructuring
Learn how to type object destructuring in TypeScript, why colons rename properties, and how to annotate destructured values correctly.
TypeScript `is` Keyword: Type Predicates and Type Guards
Learn how TypeScript `arg is Type` predicates narrow values, write safe custom type guards, and use them in filters and validation.
TypeScript export vs default export: What’s the Difference?
Learn the difference between export and default export in TypeScript, how imports work, and why TS1192 happens in real projects.
TypeScript keyof: Safely Index Objects with Dynamic Keys
Learn how to fix TypeScript implicit any index errors with noImplicitAny using keyof, typed keys, and safe dynamic object access.
TypeScript setTimeout Return Type: Node vs Window Explained
Learn why TypeScript resolves setTimeout differently in Node and browsers, and how to use the correct return type safely.
TypeScript tsconfig Paths: How Path Mapping Works with Webpack
Learn how to use tsconfig.json paths in TypeScript, when baseUrl is needed, and how to make path aliases work with Webpack.
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.