Questions
TypeScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Watch and Reload ts-node When TypeScript Files Change
Learn how to watch TypeScript files and automatically restart a ts-node dev server using practical tools and examples.
Interfaces vs Type Aliases in TypeScript
Learn the difference between interface and type in TypeScript, when to use each, and how they behave in real codebases.
JSX.Element vs ReactNode vs ReactElement in React TypeScript
Learn the difference between JSX.Element, ReactNode, and ReactElement in React TypeScript, including null returns and component typing.
JavaScript Optional Chaining with Arrays and Functions
Learn JavaScript optional chaining for array indexes and optional function calls, with syntax, examples, errors, and safe patterns.
Key-Value Pairs in TypeScript: Objects, Records, and Maps
Learn how to represent key-value pairs in TypeScript with object index signatures, Record types, and Map, with practical examples and guidance.
Loop Through a String-Keyed Dictionary in TypeScript
Learn how to iterate over keys and values in TypeScript string-keyed dictionaries using Object.keys, Object.entries, and safe typing.
Optional Chaining in TypeScript: Does TypeScript Support `?.` and What Is It Called?
Learn whether TypeScript supports the `?.` operator, what it is called, how it works, and how to use optional chaining safely in TypeScript.
React Event Types in TypeScript: onChange, onSubmit, and target
Learn the correct React event types in TypeScript, including ChangeEvent and FormEvent, and safely access input values and names.
React Refs in TypeScript: Typing DOM Elements Safely
Learn how to type React refs in TypeScript for safe DOM access, autocomplete, null checks, and modern class or function components.
Runtime Interface Type Checks in TypeScript: Why `instanceof` Does Not Work
Learn why TypeScript interfaces do not exist at runtime, why `instanceof` fails, and how to safely check object shapes instead.
Runtime Type Checks in TypeScript: Classes, Interfaces, instanceof, and Type Guards
Learn how runtime type checks work in TypeScript using instanceof, type guards, and why interfaces cannot be checked directly.
String Interpolation in TypeScript: Template Literals
Learn TypeScript string interpolation with template literals, backticks, and ${} expressions, including examples, pitfalls, and practical uses.
String vs string in TypeScript: Primitive vs Wrapper Object
Learn the difference between string and String in TypeScript, why assignment fails, and when to use the primitive type instead.
Strongly Typed Function Parameters in TypeScript
Learn how to type callback function parameters in TypeScript using function signatures instead of Function for safer code.
Subject vs BehaviorSubject in RxJS: What’s the Difference?
Learn the difference between Subject and BehaviorSubject in RxJS, including current value behavior, subscriptions, and real examples.
Suppress TypeScript Errors for One Line: TSLint vs TypeScript
Learn why TSLint disable comments do not suppress TypeScript type errors, and safely handle untyped jQuery plugin properties per line.
Testing Private Methods in Angular TypeScript with Jasmine
Learn practical ways to test Angular TypeScript classes with Jasmine, including private methods, public behavior, spies, and true #private fields.
TypeScript Arrow Functions with Generics: Syntax and Examples
Learn the syntax for generic arrow functions in TypeScript with clear examples, pitfalls, and practical usage in real code.
TypeScript Class Initialization and Field Initializers
Learn how to initialize TypeScript classes, set fields, and use constructors or object assignment instead of C#-style object initializers.
TypeScript Comments and JSDoc Documentation Syntax
Learn TypeScript comment syntax, JSDoc documentation comments, and how triple-slash directives differ from C# XML documentation comments.