Skip to content
Resume Studioby M2Toolkit

10 role-specific questions

TypeScript Developer Interview Questions & Answers

TypeScript interviews look for people who use the type system to prevent bugs rather than fight it: generics, narrowing, utility types, strictness, and knowing where types end and runtime validation begins.

Free, no sign-up. 100 questions in this role's practice pool, including behavioural, HR and situational questions.

TypeScript interview questions

Generics, narrowing, utility types and type design — what TypeScript interviews actually test.

  1. 1.

    Explain generics in TypeScript with an example.

    IntermediateTechnical

    What the interviewer is evaluating

    Whether you can write reusable, type-safe code rather than reaching for `any`.

    Key points a strong answer covers

    • Type parameters. Generics are type parameters — placeholders filled in when the function or type is used.
    • Preserve the relationship. They keep the link between input and output types, e.g. first<T>(arr: T[]): T.
    • Constraints. <T extends { id: string }> restricts what T can be.
    • Instead of any. Unlike any, generics keep checking and autocomplete.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Using generics where a plain union would do.
    • Over-constraining so callers fight the types.

    Likely follow-up questions

    • How would you type a function getProperty(obj, key)?
    • What does a default type parameter do?
    Example strong answer

    Generics are type parameters: placeholders that the caller fills in, so one function or type works for many types without losing safety. For example, function first<T>(items: T[]): T | undefined returns a User when given User[] — the relationship between input and output is preserved, which any would throw away. Constraints narrow what's allowed: function byId<T extends { id: string }>(items: T[], id: string) works for anything with an id. A common real use is a typed API helper, fetchJson<T>(url): Promise<T>, or getProperty<T, K extends keyof T>(obj: T, key: K): T[K].

    Practise this question and get feedback
  2. 2.

    What's the difference between interface and type?

    BeginnerTechnical

    What the interviewer is evaluating

    Practical judgement about everyday type declarations.

    Key points a strong answer covers

    • Both describe object shapes. For object shapes they're largely interchangeable.
    • Declaration merging. Interfaces can be re-declared and merge; type aliases can't.
    • Types do more. Type aliases can name unions, tuples, primitives, mapped and conditional types.
    • Extending. Interfaces use extends; types combine with &.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Claiming one is always faster or always better.
    • Not knowing that only types can express unions.

    Likely follow-up questions

    • When is declaration merging useful?
    • How would you extend a third-party library's type?
    Example strong answer

    For describing an object's shape they're nearly interchangeable. The differences: an interface can be declared again and the declarations merge, which is how you augment a library's types — for example adding a field to Express's Request. A type alias can name anything: unions like 'idle' | 'loading', tuples, primitives, and mapped or conditional types, which interfaces can't express. Interfaces extend with extends; types combine with intersections (&). My rule is to follow the codebase's convention — often interfaces for public object contracts and types for unions and computed types.

    Practise this question and get feedback
  3. 3.

    What is type narrowing? Show a few ways to narrow a union.

    IntermediateTechnical

    What the interviewer is evaluating

    Ability to work safely with unions and unknown data.

    Key points a strong answer covers

    • Definition. TypeScript refines a union to a more specific type inside a branch, based on control flow.
    • typeof / instanceof / in. typeof, instanceof and the in operator narrow types.
    • Discriminated unions. A shared literal field (kind) lets a switch narrow each case.
    • Type guards / exhaustiveness. Custom guards (x is User) and a never check for exhaustive switches.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Casting with as instead of narrowing.
    • Forgetting the exhaustive never check when a new case is added.

    Likely follow-up questions

    • What does value is User mean in a return type?
    • How does an exhaustive switch catch missing cases at compile time?
    Example strong answer

    Narrowing is TypeScript refining a broad type to a specific one inside a branch, based on the checks you write. typeof x === 'string' narrows primitives, instanceof Date narrows classes, and 'email' in contact narrows object unions. My favourite pattern is a discriminated union: type State = { status: 'loading' } | { status: 'error'; error: string } | { status: 'done'; data: Item[] } — switching on status gives exact types per case, and a default branch assigning to never makes the compiler flag any case I forget. For external data I write type guards like function isUser(x: unknown): x is User.

    Practise this question and get feedback
  4. 4.

    Which TypeScript utility types do you use, and for what?

    IntermediateTechnical

    What the interviewer is evaluating

    Fluency with the standard type toolbox.

    Key points a strong answer covers

    • Partial / Required. Partial<T> makes all fields optional (e.g. update payloads); Required<T> the opposite.
    • Pick / Omit. Pick and Omit derive a type with a subset of keys.
    • Record. Record<K, V> types dictionaries and lookup maps.
    • Return / Parameters / Awaited. ReturnType, Parameters, Awaited, Readonly, Exclude derive types from others.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Duplicating types by hand instead of deriving them.
    • Listing utility types without saying when you'd use them.

    Likely follow-up questions

    • How is Omit built from other types?
    • How would you make a deep partial type?
    Example strong answer

    I use them to derive types instead of duplicating them. Partial<User> types an update payload where every field is optional. Pick<User, 'id' | 'name'> and Omit<User, 'password'> give a safe public view. Record<Role, Permission[]> types a lookup table and makes sure every role is covered. ReturnType<typeof createStore> and Awaited<ReturnType<typeof fetchUser>> let the implementation be the source of truth. Readonly documents data that mustn't change, and Exclude<Status, 'deleted'> trims a union. The benefit is that when the base type changes, every derived type follows.

    Practise this question and get feedback
  5. 5.

    What's the difference between any, unknown and never?

    BeginnerTechnical

    What the interviewer is evaluating

    Type safety discipline.

    Key points a strong answer covers

    • any turns off checking. any disables type checking for that value.
    • unknown must be narrowed. unknown accepts anything but must be narrowed before use.
    • never is impossible. never is the type with no values — unreachable code, functions that always throw, exhaustive checks.
    • When to use. Use unknown for external data and catch variables.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Using any for API responses.
    • Not knowing where never is useful.

    Likely follow-up questions

    • Why is a catch (e) variable unknown with strict settings?
    • How would you validate an unknown API response at runtime?
    Example strong answer

    any switches type checking off — you can do anything with it, so errors slip through and spread. unknown also accepts any value, but you can't use it until you narrow it with a check or a type guard, so it's the safe choice for JSON from an API, user input or a caught error. never is the opposite end: a type with no possible values. It's the return type of a function that always throws, and the type left in an exhaustive switch, so assigning to never makes the compiler catch unhandled cases. For API data I'd combine unknown with a runtime validator like Zod.

    Practise this question and get feedback
  6. 6.

    What does strict mode in tsconfig change, and would you enable it on an existing project?

    IntermediateTechnical

    What the interviewer is evaluating

    Experience running TypeScript in real codebases.

    Key points a strong answer covers

    • strictNullChecks. null and undefined are no longer assignable to every type.
    • noImplicitAny. Untyped parameters become errors instead of silently any.
    • Other flags. It bundles several checks: function types, property initialisation, unknown in catch.
    • Incremental migration. On an existing project, enable flags one at a time or per folder, fixing errors gradually.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Suggesting turning it on in one go in a huge codebase with no plan.
    • Not knowing strictNullChecks is the most valuable part.

    Likely follow-up questions

    • What's the difference between ?. and !?
    • How would you stop new errors while migrating?
    Example strong answer

    strict turns on a family of checks. The most valuable is strictNullChecks: null and undefined are no longer silently allowed everywhere, which catches a whole class of runtime crashes. noImplicitAny makes untyped parameters errors, and others check function parameter types, class property initialisation and make catch variables unknown. Yes, I'd enable it on an existing project, but gradually: turn on one flag at a time, fix the errors folder by folder, and use // @ts-expect-error with a ticket only where needed, while CI prevents new violations.

    Practise this question and get feedback
  7. 7.

    Explain mapped and conditional types, with a real use case.

    AdvancedTechnical

    What the interviewer is evaluating

    Advanced type-level programming for library or shared-code work.

    Key points a strong answer covers

    • Mapped types. Mapped types build a new type by iterating over keys: { [K in keyof T]: ... }.
    • Conditional types. T extends U ? X : Y chooses a type based on another.
    • infer. infer extracts a type inside a conditional, e.g. a promise's value.
    • Real use case. E.g. a form-errors type with the same keys as the form values.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Writing clever types that nobody on the team can read.
    • No practical example.

    Likely follow-up questions

    • How is ReturnType implemented?
    • What is a distributive conditional type?
    Example strong answer

    A mapped type iterates over the keys of another type to build a new one: type FormErrors<T> = { [K in keyof T]?: string } gives a form's error object exactly the same keys as its values, so adding a field updates both. A conditional type picks a type based on a condition: T extends string ? 'text' : 'other'. With infer you can extract parts — type Unwrap<T> = T extends Promise<infer V> ? V : T is essentially how Awaited works, and ReturnType uses the same trick. I use these in shared code like typed event emitters, but keep them commented and tested, because readability matters more than cleverness.

    Practise this question and get feedback
  8. 8.

    Should you use enums in TypeScript? What are the alternatives?

    IntermediateTechnical

    What the interviewer is evaluating

    Awareness of runtime cost and trade-offs.

    Key points a strong answer covers

    • Enums emit code. Regular enums generate a runtime object (and numeric enums a reverse mapping).
    • Union of literals. A union of string literals is often simpler and erases completely.
    • as const objects. An as const object gives runtime values plus a derived union type.
    • Trade-offs. Numeric enums accept any number; const enums have tooling issues with isolated modules.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Not knowing enums exist at runtime.
    • Treating the choice as purely stylistic.

    Likely follow-up questions

    • How do you get a union type from an as const object?
    • Why might a build tool reject const enums?
    Example strong answer

    Enums work, but they're one of the few TypeScript features that emit runtime code, and numeric enums are loose — any number is assignable. Most of the time I use a union of string literals, like type Status = 'draft' | 'published', which erases completely and reads clearly. When I also need the values at runtime — for a dropdown, say — I use an object with as const and derive the type with typeof STATUS[keyof typeof STATUS]. const enum avoids the runtime object but doesn't play well with isolated-module compilers like esbuild or SWC. So: unions by default, as const objects when I need values, enums if the codebase already standardises on them.

    Practise this question and get feedback
  9. 9.

    TypeScript types disappear at runtime. How do you make sure API data really matches your types?

    AdvancedTechnical

    What the interviewer is evaluating

    Understanding the boundary between compile-time and runtime safety.

    Key points a strong answer covers

    • Types are erased. Types are erased when compiled, so they can't check data that arrives at runtime.
    • Validate at the boundary. Validate external data where it enters the app (API responses, forms, env vars).
    • Schema libraries. Libraries like Zod define a schema once and infer the type from it.
    • Handle failures. Decide what to do when validation fails: log, show an error, or fall back.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Using as User on a fetch response and calling it type-safe.
    • Validating deep inside the app instead of at the boundary.

    Likely follow-up questions

    • How would you keep server and client types in sync?
    • What's the cost of validating every response?
    Example strong answer

    Type annotations are erased at compile time, so const user = await res.json() as User is just a promise to the compiler — nothing checks it. I validate at the boundary, where data enters the app: API responses, form input, URL params and environment variables. I use a schema library such as Zod: define the schema once, infer the TypeScript type from it with z.infer, and call safeParse on the data, so the type and the check can't drift apart. When parsing fails I log the details and show a clear error rather than letting undefined values crash something three screens later. Where possible I also generate client types from the server's OpenAPI spec.

    Practise this question and get feedback
  10. 10.

    When would you use function overloads instead of a union parameter?

    AdvancedTechnical

    What the interviewer is evaluating

    Designing precise public APIs.

    Key points a strong answer covers

    • Return type depends on input. Overloads let the return type depend on which argument shape was passed.
    • Overload signatures + implementation. You write several call signatures and one implementation signature that's not visible to callers.
    • Alternatives. Often a generic or a union parameter is simpler.
    • Readability. Overloads give callers precise autocomplete and errors.

    Suggested answer structure

    1. Define it in one sentence.
    2. Explain how it works underneath.
    3. Give a practical example from code or a project.
    4. Close with a trade-off, pitfall or when you'd use it.

    Common mistakes

    • Using overloads where one union signature is enough.
    • Not knowing the implementation signature isn't callable.

    Likely follow-up questions

    • How would you type createElement('a') returning HTMLAnchorElement?
    • What's the order rule for overload signatures?
    Example strong answer

    I use overloads when the return type depends on the shape of the input in a way a single union can't express. For example, parse(input: string): Doc and parse(input: string[]): Doc[] — with a union parameter the caller would get Doc | Doc[] and have to narrow it. With overloads you declare each call signature, then one implementation signature that handles all cases; callers only see the overloads. TypeScript picks the first matching overload, so specific signatures go first. Often a generic or conditional type works too, but overloads usually give clearer autocomplete and error messages, which matters for shared utilities.

    Practise this question and get feedback

Behavioural & HR questions you'll also get

These come up in almost every typescript developer interview. Story questions are best answered with STAR — Situation, Task, Action, Result.

  • Tell me about yourself.

    BeginnerHR

    What the interviewer is evaluating

    Whether you can give a concise, relevant pitch that frames your experience around this job.

    Key points a strong answer covers

    • Present. Start with your current role and what you do.
    • Relevant past. Pick the most relevant past experience.
    • Strength / achievement. Include one strength or achievement with evidence.
    • Why this role. Finish with why this role is the next step.

    Suggested answer structure

    1. Present — your current role in one or two sentences.
    2. Past — the experience most relevant to this job.
    3. Proof — one achievement or strength with evidence.
    4. Future — why this role is the logical next step.

    Common mistakes

    • Reciting your whole CV chronologically.
    • Personal life story unrelated to the job.
    • Going over two minutes.

    Likely follow-up questions

    • Why are you looking to leave your current role?
    • What would your manager say is your biggest strength?
    Example strong answer

    I'm a front-end developer with four years' experience, currently at a fintech start-up where I build the customer dashboard in React and TypeScript. Before that I spent two years at an agency building e-commerce sites, which taught me to work fast with lots of different clients. The thing I'm proudest of recently is leading our move to a shared component library, which cut the time to build new screens by about a third. I'm now looking for a role where I can work on a larger product with a strong design system, which is exactly what drew me to this position.

  • Why should we hire you?

    BeginnerHR

    What the interviewer is evaluating

    Whether you understand the role and can match your strengths to its needs with evidence.

    Key points a strong answer covers

    • Role's needs. Show you understand what the role needs.
    • Matching strengths. Match two or three strengths to those needs.
    • Evidence. Back each with evidence.
    • Enthusiasm. Close with genuine enthusiasm.

    Suggested answer structure

    1. Name the two or three things the role needs most.
    2. Match each with your experience and evidence.
    3. Add what makes you different.
    4. Finish with genuine interest.

    Common mistakes

    • Generic claims like 'I'm hardworking' with no evidence.
    • Comparing yourself to other candidates you don't know.

    Likely follow-up questions

    • What would you do in your first 90 days?
    • What's one area where you'd need support?
    Example strong answer

    From the job description and our conversation, you need someone who can take ownership of the customer onboarding process, work with sales and product, and improve the numbers. I've done exactly that for three years: at my current company I redesigned onboarding for new accounts and cut the time to first value from 14 days to 6. I'm comfortable working across teams — I run a weekly session with sales and product on customer feedback — and I'm very data-driven, so I'd measure everything from day one. I'm also genuinely excited about your product, because it solves a problem I've seen customers struggle with.

  • Tell me about a time you disagreed with a teammate. How did you handle it?

    BeginnerBehavioural

    What the interviewer is evaluating

    Handling conflict constructively and keeping relationships.

    Key points a strong answer covers

    • Listened to their view. Show you listened to understand their view.
    • Used facts / common goal. Bring it back to facts or a shared goal.
    • Resolution & relationship. Resolve it and keep the relationship.

    Suggested answer structure

    1. Situation — one or two sentences of context.
    2. Task — what you were responsible for.
    3. Action — what you did, step by step (say “I”).
    4. Result — what changed, with a number if you can back it up.
    5. Reflection — what you learned or would do differently.

    Common mistakes

    • Making the other person the villain.
    • A story where you were simply right and they gave in.

    Likely follow-up questions

    • What if you couldn't reach agreement?
    • Have you ever been wrong in a disagreement?
    Example strong answer (a fictional story — use your own)

    On a website rebuild, a senior designer wanted an animated, image-heavy homepage, and I was worried it would hurt mobile load times and SEO. As the developer responsible for performance, I needed us to agree before the sprint started. I asked her to walk me through what she was trying to achieve — she wanted the brand to feel premium. I built two quick prototypes, one with her full design and one with lighter animations, and we tested both on a mid-range phone together. Hers took nearly six seconds to load. We agreed on a version that kept the key animation but lazy-loaded the rest. The page launched loading in under two seconds, and she later asked me to review designs earlier. I learned that testing together beats debating.

  • Tell me about a mistake you made and what you learned.

    BeginnerBehavioural

    What the interviewer is evaluating

    Honesty, accountability and learning.

    Key points a strong answer covers

    • Real mistake owned. Own a real mistake.
    • Fixed it. Show how you fixed it and who you told.
    • Changed behaviour. Show what you changed afterwards.

    Suggested answer structure

    1. Situation — one or two sentences of context.
    2. Task — what you were responsible for.
    3. Action — what you did, step by step (say “I”).
    4. Result — what changed, with a number if you can back it up.
    5. Reflection — what you learned or would do differently.

    Common mistakes

    • Choosing a fake mistake like 'I work too hard'.
    • Blaming others.

    Likely follow-up questions

    • How did your manager react?
    • How do you know you haven't repeated it?
    Example strong answer (a fictional story — use your own)

    In my first year as a marketing coordinator, I sent a promotional email to our whole list with the wrong discount code — I'd tested the email but not clicked the code itself. Within an hour customers were complaining that it didn't work. I told my manager immediately, set the wrong code to apply the discount too, and sent a short correction email with an apology. We lost very little revenue, and some customers replied thanking us for the quick fix. Since then I use a pre-send checklist that includes testing every link and code as a customer would, and I asked for a second person to check any campaign to more than 10,000 people.

  • Describe a situation where you worked under pressure or to a tight deadline.

    BeginnerBehavioural

    What the interviewer is evaluating

    Prioritisation, composure and delivery.

    Key points a strong answer covers

    • The pressure. Make the pressure concrete.
    • Prioritised. Show how you prioritised.
    • Communicated. Show how you kept people informed.
    • Delivered. Show the outcome.

    Suggested answer structure

    1. Situation — one or two sentences of context.
    2. Task — what you were responsible for.
    3. Action — what you did, step by step (say “I”).
    4. Result — what changed, with a number if you can back it up.
    5. Reflection — what you learned or would do differently.

    Common mistakes

    • Glorifying working all night as the solution.
    • No mention of prioritising.

    Likely follow-up questions

    • What would you do if it was clear you couldn't make the deadline?
    • How do you stop pressure affecting quality?
    Example strong answer (a fictional story — use your own)

    Two days before a client presentation, our analyst fell ill and I had to finish the market research report she'd been leading. I listed everything left and asked the account director which sections the client cared about most — pricing and competitor comparison. I focused on those, reused verified data from our previous report, and moved the appendix to a follow-up email. I sent a short update each evening so nobody was surprised. We delivered the core report on time, the client approved the next phase, and the appendix followed two days later. I learned to ask early what matters most rather than trying to do everything equally well.

  • What would you do if you realised you were going to miss a deadline?

    BeginnerSituational

    What the interviewer is evaluating

    Transparency and problem solving.

    Key points a strong answer covers

    • Tell people early. Flag it as soon as you know.
    • Assess the gap. Work out how far off you are.
    • Options. Offer options: reduced scope, help, a new date.
    • Prevent repeats. Learn why it happened.

    Suggested answer structure

    1. Clarify the situation and what's at stake.
    2. Say what you'd do first, and why.
    3. Explain who you'd involve and how you'd communicate.
    4. Describe how you'd check the outcome and prevent a repeat.

    Common mistakes

    • Waiting until the deadline to say anything.
    • Promising you'll just work all night.

    Likely follow-up questions

    • What if your manager is unavailable?
    • Has this happened to you?
    Example strong answer

    I'd tell the person depending on it as soon as I realised, not at the deadline. Before that conversation I'd work out how far off I am and why, so I could offer options: delivering the most important part on time and the rest a few days later, getting help from a colleague, or agreeing a new date. Then I'd let them decide what works best for them, and keep them updated. Afterwards I'd look at why it slipped — usually underestimating something — so I plan better next time.

Ready to answer them out loud?

Run a timed typescript developer mock interview, type or speak your answers, and get a score breakdown with what to improve.

Interview questions for related roles