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.

typescriptjavascript

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.

typescriptangularangular-cli

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.

typescripttypescript-conditional-types

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.

typescriptjavascript

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.

typescriptangularangular-routing

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.

typescripttypescript1.8

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.

typescript

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.

typescriptvisual-studio-code

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.

typescriptangularangular-material

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.

typescript

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.

typescriptangularng-build

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.

typescriptjavascriptarrays

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.

typescript

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.

typescriptnull-check

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.

typescriptjavascriptenums

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.

typescriptjavascript

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.

typescriptjson

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.

typescriptjavascript

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.

typescript

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.

typescriptclass-constants

Page 3 of 9 - 162 questions