HomeInterview QuestionsTypeScript Interview QuestionsTop 10
🔷
Free Study Guide · 2025

Top 10 TypeScriptInterview Questions & Answers (2025)

TypeScript is now expected in most frontend and full-stack roles at Indian product companies. These questions cover everything from basic type annotations to advanced generics and utility types asked at Razorpay, CRED, Zepto, and modern startups.

10 questions
Detailed answers
100% free
Also available:All 15 questions →
1What is TypeScript and why do you use it?
TypeScript is a statically-typed superset of JavaScript developed by Microsoft that compiles to plain JavaScript. It adds optional static typing, interfaces, enums, generics, and better tooling (autocomplete, error detection at compile time). Benefits: catches type errors before runtime, improves code documentation through types, and enables safer refactoring. It's the default choice for new React and Node.js projects.
2What is the difference between type and interface?
Both define the shape of an object. Key differences: interfaces can be extended with extends and merged via declaration merging (defining the same interface twice merges them). Type aliases can represent primitives, unions, tuples, and mapped types — more expressive. For object shapes, either works; prefer interface for public APIs (declaration merging is useful) and type for unions, intersections, and complex type expressions.
3What are generics in TypeScript?
Generics allow you to write reusable code that works with multiple types while maintaining type safety. function identity<T>(arg: T): T { return arg; } — the T is a type variable that's determined at call time. Generics are used throughout TypeScript's standard library: Array<T>, Promise<T>, Map<K,V>. Constraints (<T extends object>) narrow what types are accepted.
4What is the difference between any, unknown, and never?
any disables type checking entirely — avoid it as it defeats TypeScript's purpose. unknown is type-safe any — you must narrow the type with typeof or instanceof before using it. never represents a value that never occurs — the return type of functions that always throw, infinite loops, or branches that are logically impossible. It's also the bottom type (no value is assignable to never).
5What are union types and intersection types?
A union type (A | B) means a value can be of type A or B. A function accepting string | number handles both. An intersection type (A & B) combines multiple types — a value must satisfy all of them. Intersections are used to compose types: type Admin = User & { adminLevel: number }. Use unions for alternatives; use intersections for combinations.
6What are TypeScript utility types?
Built-in generic types that transform existing types: Partial<T> makes all properties optional; Required<T> makes all required; Readonly<T> makes all read-only; Pick<T, K> selects a subset of properties; Omit<T, K> excludes properties; Record<K, V> creates an object type; Exclude<T, U> removes union members; ReturnType<T> extracts a function's return type. Mastering these eliminates repetitive type definitions.
7What is type narrowing?
Type narrowing is TypeScript's ability to refine a type to a more specific type within a conditional block. It uses type guards: typeof (typeof x === 'string'), instanceof (x instanceof Date), truthiness checks, equality checks, and discriminated unions. Custom type predicates (function isString(x: any): x is string) let you create reusable narrowing functions.
8What is a discriminated union?
A discriminated union is a union of types that share a common literal property (the discriminant) allowing TypeScript to narrow to the correct type in a switch/if. Example: type Shape = { kind: 'circle'; radius: number } | { kind: 'rect'; width: number }. Switching on shape.kind lets TypeScript know the exact shape in each branch. It's the idiomatic TypeScript pattern for modelling variant types.
9What are TypeScript decorators?
Decorators are an experimental feature (enabled with experimentalDecorators) that add metadata and modify classes, methods, properties, or parameters using @syntax. They're central to Angular and used in NestJS for @Injectable(), @Controller(), @Get(). Under the hood they're functions that receive the decorated target as an argument. TypeScript 5.0 introduced the TC39 Stage 3 decorators proposal as the new standard.
10What is the difference between interface and abstract class in TypeScript?
An interface defines a contract (shape) with no implementation — multiple interfaces can be implemented. An abstract class can have implemented methods, constructors, and properties, but cannot be instantiated directly. A class can only extend one abstract class. Use interfaces for pure contracts; use abstract classes when you want to share partial implementations while enforcing a contract.
See all 15 TypeScript questions →
Level up your prep
Get company-specific TypeScript questions
Upload your resume → get questions tailored to Google, Amazon, TCS, and 50+ companies.
Try AI Interview Prep →
© 2025 CareerLens · Home · Interview Questions · Pricing