TypeScript Interview Prep

100+ TypeScript Interview Questions

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.

🚀 Practice Now — It's Free📚 TypeScript Topics✍️ TS Blog
57+
Questions
12
Categories
7+
Companies
27+
With Code
🏢 Asked at:MicrosoftGoogleAtlassianRazorpayMetaFlipkartCRED

All Questions by Category

Advanced Types3

advancedWhat are mapped types and how do you use them beyond the built-in utility types?advancedWhat are conditional types and how do you use infer for type extraction?advancedWhat are template literal types in TypeScript?

Class Patterns3

advancedPrivate field accessed outside class — wrong data exposed
MicrosoftGoogle
debug
advancedAbstract class instantiated directly — unexpected behavior
MicrosoftAtlassian
debug
expertClass missing interface implementation — methods silently absent
MicrosoftGoogle
debug

Classes & OOP5

beginnerWhat are access modifiers in TypeScript — public, private, protected, readonly?coreWhat are abstract classes in TypeScript and when should you use them?coreWhat is the difference between implements and extends in TypeScript?coreHow do decorators work in TypeScript, and what are they used for?advancedWhat are static members and class fields in TypeScript?

Conditional Types4

advancedIsArray conditional — resolves based on type check
MicrosoftGoogle
output
advancedNonNullable conditional — null and undefined are removed
MicrosoftAtlassian
output
expertinfer extracts the wrapped type from a generic container
MicrosoftGoogle
output
expertDistributive conditional — union members resolved independently
MicrosoftGoogle
output

Generic Constraints3

advancedMissing keyof constraint — unsafe property access
MicrosoftAtlassian
debug
expertMissing extends object constraint — primitive passed to object utility
MicrosoftGoogle
debug
expertGeneric function returns any instead of constrained type
MicrosoftAtlassian
debug

Generics7

beginnerWhat are generics and why are they useful in TypeScript?coreWhat are generic constraints and how do you use the extends keyword with them?coreWhat are default type parameters in TypeScript generics?coreWhat is conditional generic typing — how do you write T extends U ? X : Y?advancedHow do generic functions differ from generic types? Show examples of each.advancedWhat is the Partial, Required, and Readonly pattern when building generic utility functions?

Generics & Bounds4

advancedGeneric identity — T resolves to the argument type
MicrosoftGoogle
output
advancedextends constraint — keyof and property access
MicrosoftAtlassian
output
expertGeneric Array utilities — map and filter type resolution
MicrosoftMeta
output
expertConstrained generic with default — what type is inferred
MicrosoftGoogle
output

Type Errors3

coreWrong type assignment causes silent wrong output
MicrosoftGoogle
debug
advancedAccessing property on potentially undefined value
MicrosoftAtlassian
debug
advancedReturning wrong type from a function — silently truncates data
MicrosoftGoogle
debug

Type Inference4

coretypeof narrowing determines which branch runs
MicrosoftAtlassian
output
advancedConst assertion — literal type vs widened type
MicrosoftGoogle
output
advancedDiscriminated union narrowing via switch
MicrosoftMeta
output
expertReturnType inference — function return shapes
MicrosoftGoogle
output

Type System8

beginnerWhat is type inference in TypeScript and when does it kick in?beginnerWhat is the difference between any, unknown, and never in TypeScript?coreWhat are type assertions and when should you use them?beginnerWhat is structural typing (duck typing) in TypeScript?coreWhat are union types and intersection types? When do you use each?coreWhat are type guards and how do you create custom ones?

Union & Intersection3

advancedUnion type — in operator narrows to the correct variant
MicrosoftAtlassian
output
advancedIntersection type — must satisfy all merged properties
MicrosoftGoogle
output
expertUnion narrowing exhaustion — never in the default case
MicrosoftMeta
output

Utility Types10

beginnerWhat are Partial, Required, and Readonly utility types?beginnerWhat are Pick and Omit utility types and when should you use them?coreWhat is the Record utility type and when is it useful?coreWhat are ReturnType, Parameters, and InstanceType utility types?coreWhat are Exclude and Extract utility types?advancedWhat are Awaited and NonNullable utility types?

Core TypeScript Topics

Types vs InterfacesGenericsUtility TypesType Guards & NarrowingMapped TypesConditional TypesBrowse All Topics →

Frequently Asked TypeScript Interview Questions

What is TypeScript and why should you use it?

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.

What is the difference between type and interface in TypeScript?

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.

What are TypeScript generics and when do you use them?

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.

What is the difference between any, unknown, and never in TypeScript?

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.

What are TypeScript utility types?

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.

What is type narrowing in TypeScript?

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.

What are TypeScript decorators?

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.

What is the difference between extends and implements in TypeScript?

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.

What are mapped types in TypeScript?

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.

What are conditional types in TypeScript?

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.

How to Prepare for TypeScript Interviews

🧠

Understand the type system

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.

💻

Practice type inference

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.

🐛

Debug type errors

Practice with code that has type errors — constraint violations, incompatible assignments, missing properties. Real interview questions are always logical, not syntax mistakes.

📐

Master the fundamentals first

Types vs interfaces, generics, utility types, and type guards cover 80% of TypeScript interviews. Get those solid before advanced topics.

⏱️

Write TypeScript daily

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.

Related Resources

Ready to practice?

Interactive TypeScript questions with instant feedback. Predict type outputs, find bugs, and master TypeScript.

Start Practicing Free →⚡ Daily Sprint