Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Fixing Type 'string' Is Not Assignable to Type in TypeScript Union Types
Learn why TypeScript rejects string to literal union assignments and how to safely use custom types like Fruit.
Generate Components in a Specific Folder with Angular CLI
Learn how to generate Angular components in a specific folder using Angular CLI, including child components and project structure tips.
Get Function Argument Types with Parameters in TypeScript
Learn how to extract function parameter types as tuples in TypeScript using Parameters<T>, conditional types, and practical examples.
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 URL Query Parameters in Angular 5 with ActivatedRoute
Learn how to read URL query parameters in Angular 5 with ActivatedRoute, snapshots, observables, and practical routing examples.
Get a Function Return Type in TypeScript with ReturnType
Learn how to extract a TypeScript function's return type with ReturnType, typeof, generics, overloads, and practical examples.
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.
Hide JavaScript Source Map Files in VS Code with files.exclude
Learn how to hide generated .js and .js.map files in Visual Studio Code Explorer using workspace settings and glob patterns.
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 a Variable Type in TypeScript with typeof
Learn how to check a variable's runtime type in TypeScript using typeof, type guards, union types, and safe type narrowing.
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.