Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Get Keys of a TypeScript Interface as an Array of Strings
Learn how to get TypeScript interface keys as string arrays using keyof, typed helper patterns, and runtime-safe alternatives.
Get an Object's Class Name at Runtime in TypeScript
Learn how to get an object's class name at runtime in TypeScript, how constructors work, and common pitfalls with minification.
How Angular Material mat-form-field Works with MatFormFieldControl
Learn why Angular Material shows 'mat-form-field must contain a MatFormFieldControl' and how content projection affects matInput.
How to Add a Custom Property to window in TypeScript
Learn how to declare custom properties on the window object in TypeScript using global interface augmentation and safe examples.
How to Allow External Access to an Angular App Beyond localhost
Learn why an Angular app works on localhost but not by IP, and how to bind the dev server for external network access safely.
How to Check Whether an Array Contains a String in TypeScript
Learn how to check whether a string exists in an array in TypeScript using includes, indexOf, and common real-world patterns.
How to Check for null and undefined in TypeScript
Learn how to check for both null and undefined in TypeScript using strict comparisons, == null, and type-safe patterns.
How to Check if a Value Exists in an Enum-Like Object in TypeScript
Learn simple ways to check whether a number exists in an enum-like object in TypeScript, with examples and common mistakes.
How to Clone Class Objects in TypeScript Without Constructor Errors
Learn how to clone class instances in TypeScript, including deep vs shallow copy, constructor typing, and safer patterns for nested objects.
How to Convert a JSON Object to a TypeScript Class
Learn how JSON-to-class conversion works in TypeScript, why type assertions are limited, and how to create real class instances safely.
How to Convert a String to a Number in TypeScript
Learn how to convert a string to a number in TypeScript using Number, unary plus, parseInt, and parseFloat with examples and pitfalls.
How to Convert a String to an Enum in TypeScript
Learn how to convert a string to an enum in TypeScript, including enum lookup, validation, reverse mapping, and common pitfalls.
How to Create Class Constants in TypeScript
Learn how to represent class constants in TypeScript using readonly and static readonly properties with clear examples and common pitfalls.
How to Create an Object from an Interface in TypeScript
Learn how to use a TypeScript interface to describe an object and correctly create and initialize that object in practice.
How to Declare Nullable Types in TypeScript Interfaces
Learn how to make properties nullable in TypeScript interfaces using union types, optional fields, and null-safe patterns.
How to Define an Array with Multiple Types in TypeScript
Learn how to type arrays with mixed values in TypeScript using union types and tuples, with examples, pitfalls, and practical use cases.
How to Determine the Active Route in Angular
Learn how to detect and style the active route in Angular using routerLinkActive, Router, and ActivatedRoute with practical examples.
How to Dynamically Assign Properties to an Object in TypeScript
Learn how to add dynamic properties to objects in TypeScript using index signatures, Record, type assertions, and safe typing patterns.
How to Enforce String Values in Indexed TypeScript Objects
Learn how to type indexed objects in TypeScript so string keys only map to string values using index signatures and Record.
How to Exclude a Property from a Type in TypeScript
Learn how to exclude one property from a type in TypeScript using Omit, Pick, and mapped types with clear examples.