Complete TypeScript interview prep covering types vs interfaces, generics, utility types, type guards, mapped types, decorators, and more. Questions asked at Google, Microsoft, Atlassian, Razorpay, Flipkart and other top tech companies.
TypeScript is a statically typed superset of JavaScript that compiles to plain JavaScript. It adds optional type annotations, interfaces, generics, and advanced type features that catch errors at compile time rather than runtime. Teams use it to improve code maintainability, enable better IDE tooling, and make large codebases easier to refactor safely.
Both type aliases and interfaces can describe object shapes, but they have key differences. Interfaces support declaration merging (multiple declarations merge into one) and are generally preferred for defining object shapes and class contracts. Type aliases are more flexible — they can represent primitives, unions, intersections, tuples, and mapped types. In most cases, prefer interface for objects and type for everything else.
Generics are type variables that let you write reusable code that works with multiple types while maintaining type safety. You use them when a function or class should operate on different types but the types are related (e.g., a function that returns the same type it receives). Without generics you'd have to use any and lose type safety.
any disables type checking entirely — you can assign anything to it and do anything with it. unknown is the safe alternative — you can assign anything to it but must narrow the type before using it. never represents a type that can never occur — used as the return type of functions that always throw or never return, and appears in exhaustive checks.
Utility types are built-in generic types that transform existing types. Common ones: Partial<T> makes all properties optional, Required<T> makes all required, Readonly<T> prevents mutations, Pick<T, K> selects a subset of keys, Omit<T, K> removes keys, Record<K, V> creates an object type, ReturnType<F> extracts a function's return type, and Awaited<T> unwraps a Promise type.
Type narrowing is the process of refining a broad type to a more specific one within a conditional block. TypeScript recognizes typeof, instanceof, in operator checks, equality checks, and truthiness checks as narrowing constructs. You can also write custom type guard functions using the 'is' syntax (value is Type) to narrow types in reusable ways.
Decorators are a stage-3 JavaScript proposal (enabled in TypeScript with experimentalDecorators) that let you annotate and modify classes, methods, properties, and parameters. They are functions that receive the target they decorate and can modify its behavior. Common uses include dependency injection frameworks (NestJS, Angular), ORMs (TypeORM), and validation libraries.
extends is used for inheritance — a class that extends another inherits its implementation. implements is used to declare that a class satisfies a contract (interface or type) without inheriting any implementation. A class can implement multiple interfaces but can only extend one class. Interfaces can also extend other interfaces.
Mapped types transform all properties of an existing type by iterating over its keys. They use the syntax { [K in keyof T]: ... } and are the mechanism behind utility types like Partial, Required, and Readonly. You can also add or remove modifiers (+?, -?, +readonly, -readonly) and remap keys using the as clause.
Conditional types follow the syntax T extends U ? X : Y — if T is assignable to U, the type resolves to X, otherwise Y. They enable type-level logic for extracting, filtering, and transforming types. Built-in utility types like NonNullable, ReturnType, and Awaited are all implemented with conditional types.
Focus on why TypeScript's structural typing works the way it does — assignability, narrowing, and distribution. Interviewers can tell when you've only memorized syntax.
Use output prediction questions to train your mental model of what TypeScript infers. If you can predict what a type resolves to, you truly understand it.
Practice with code that has type errors — constraint violations, incompatible assignments, missing properties. Real interview questions are always logical, not syntax mistakes.
Types vs interfaces, generics, utility types, and type guards cover 80% of TypeScript interviews. Get those solid before advanced topics.
The fastest way to learn TypeScript is to use it in a real project — type props in React, add generics to utility functions, and let the compiler guide you.
Interactive TypeScript questions with instant feedback. Predict type outputs, find bugs, and master TypeScript.