Questions

TypeScript questions

Choose a question page, learn the concept, then test your understanding with a quiz.

@Directive vs @Component in Angular: Differences, Use Cases, and When to Use Each

Learn the difference between @Directive and @Component in Angular, including use cases, examples, and when to choose each.

typescriptangular

Angular (change) vs (ngModelChange): What’s the Difference?

Learn the difference between Angular (change) and (ngModelChange), when each fires, and which one to use in forms and inputs.

typescriptjavascripthtmlangular

Angular formControl Error with Material Autocomplete: Why It Happens and How to Fix It

Learn why Angular says it cannot bind to formControl and how to fix Reactive Forms setup with Angular Material Autocomplete.

typescriptangularangular-material2angular-forms

Angular formGroup Error Explained: Fixing 'Can't bind to formGroup' in Reactive Forms

Learn why Angular shows 'Can't bind to formGroup' and how to fix it by importing ReactiveFormsModule correctly.

typescriptangularangular2-forms

Can You Override an Interface Property Type in TypeScript Declaration Files?

Learn whether you can change an interface property type from a .d.ts file in TypeScript, and what safe alternatives to use instead.

typescriptjavascripttypescript-typings

Fix "Element implicitly has an 'any' type" in TypeScript Object Indexing

Learn why TypeScript rejects string object indexing and how to fix it with keyof, unions, and typed object keys in React.

typescript

Fix "Property has no initializer" in Angular TypeScript Components

Learn why Angular TypeScript shows "Property has no initializer" and how to fix it using defaults, optional properties, or definite assignment.

typescriptangular

Fix 'Could not find a declaration file for module' in TypeScript

Learn why TypeScript cannot find declaration files for a package and how to fix it with types, package.json, and module resolution.

typescriptnode-modules

Fix TS2304 Cannot Find Name 'require' in TypeScript for Node.js

Learn why TypeScript shows TS2304 for 'require' in Node.js and how to fix it using Node type definitions and correct project setup.

typescriptnode.jsdefinitelytyped

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 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 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 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

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.

typescript

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.

typescriptnullable

Page 1 of 4 - 62 questions

PreviousNext