Frontend · Fresher-relevant
TypeScript interview questions on type system, generics, interfaces, and compiler options — increasingly required at Indian product startups.
Commonly asked at: Commonly asked at product companies and startups building with React/Next.js/Angular, such as Flipkart, Zomato, and Razorpay — general pattern, not company-verified.
Company names below are mentioned only to indicate the general type/level of interview these questions are common at, based on widely known industry patterns. This content is not affiliated with, endorsed by, or sourced from any confidential material of the named companies. All trademarks belong to their respective owners.
What is TypeScript, and how is it different from JavaScript?
Tip: Say the one-line definition first, then the "why it matters" — don't jump straight to features.
TypeScript is a superset of JavaScript that adds static typing. It compiles down to plain JS, so it runs anywhere JS runs, but it catches type errors at compile time instead of at runtime, which makes large codebases much easier to maintain and refactor.
Interfaces vs type aliases — what's the difference?
Tip: Lead with "they're similar," then give the one real distinguishing feature — declaration merging.
They're mostly interchangeable for describing object shapes, but type aliases are more flexible — they can represent unions, tuples, and primitives, which interfaces can't. The key practical difference is that interfaces can be reopened and extended through declaration merging, while types can't.
any vs unknown vs never — what's the difference?
Tip: Say clearly that `any` should be avoided — that opinion is expected and shows maturity.
`any` disables type checking entirely, which kind of defeats the point of using TypeScript if overused. `unknown` also accepts anything, but forces you to narrow the type with a check before you can use it — safer. `never` represents a value that should never occur, like the return type of a function that always throws.
What are generics, and why are they useful?
Tip: Use a one-liner example function — it's much clearer than describing generics abstractly.
Generics let you write reusable functions or components that work across multiple types while keeping type safety. For example, `function identity<T>(arg: T): T` works for any type, and TypeScript still knows the exact return type — unlike using `any`, which would lose that information.
extends vs implements — what's the difference?
Tip: Keep it short — this is a quick-recall syntax question.
`extends` is used between interfaces (or classes) to inherit from another. `implements` is used on a class to say it fulfills an interface's contract — the class has to actually provide concrete implementations for everything declared.
Union types vs intersection types?
Tip: Give one small example of each — abstract explanations of `|` and `&` don't stick without one.
A union type means a value can be either type — like a status that's `"success" | "error"`. An intersection type means a value must satisfy both types at once, which is common when merging two smaller interfaces into one combined shape.
What is type narrowing?
Tip: Name the common narrowing tools — typeof, instanceof, in — interviewers often want to hear these keywords.
Type narrowing is how TypeScript refines a broader type into a more specific one inside a code block, usually using checks like `typeof`, `instanceof`, or `in`. So inside an `if (typeof value === "string")` block, TypeScript treats `value` as a string for the rest of that block.
What are decorators in TypeScript?
Tip: Mention where they're actually used in practice (Angular/NestJS) — it grounds an otherwise abstract feature.
Decorators are special declarations you attach to classes, methods, or properties to modify or annotate their behavior — Angular and NestJS use them heavily, like `@Component` or `@Injectable`. They're still an experimental feature, so you need `experimentalDecorators` enabled in tsconfig.
What is the difference between an enum and a union of string literals?
Tip: Mention the runtime footprint difference — that's the detail experienced devs bring up.
An enum creates an actual JavaScript object at runtime that you can iterate over, but it adds some bundle size and can behave unexpectedly with numeric enums. A union of string literals, like `"pending" | "done"`, is purely a compile-time construct with zero runtime cost, which is why a lot of teams prefer it for simple fixed sets of values.
⭐ Scenario: You inherited a large JavaScript codebase and were asked to migrate it to TypeScript incrementally. How would you approach it?
Tip: This is scenario-based — describe an actual step-by-step plan, not just theory.
Situation: I was handed a large, actively-developed JS codebase that needed type safety without a disruptive big-bang rewrite.
Task: Migrate to TypeScript incrementally, without blocking ongoing feature work.
Action: I started by enabling `allowJs` and `checkJs` so TypeScript could coexist with existing JS files, converted the most frequently modified/high-risk files first, and used `any` sparingly as a temporary escape hatch to keep momentum, tightening types file by file afterward.
Result: The migration progressed alongside regular feature work without a big freeze, and type coverage improved steadily over a few sprints instead of one risky rewrite.
InterviewEra generates role-specific questions using your actual projects and skills. Get scored feedback on technical depth, clarity, and structure — free to start.