TypeScript Interview Questions and Answers (2026): 35 Questions by Level

TypeScript Interview Questions 2026

Last updated: 27 November 2026

Short answer: TypeScript interviews test types you use every day (any vs unknown, interfaces, unions, narrowing), generics and utility types, typing React and async code, and for senior roles, type design and build speed. Below are 35 questions with short answers and code: 12 for freshers, 13 for 2–5 years and 10 senior. In India, TypeScript mostly shows up next to React: on 27 November 2026, 112 of the 870 frontend developer listings on Weekday named TypeScript, and 88 of the 275 that named React also named TypeScript. The current release is TypeScript 7.0.2, the new native compiler.

TypeScript 7.0 came out on 8 July 2026. It's a port of the compiler to Go, and Microsoft says it's often about 10 times faster than TypeScript 6.0 (TypeScript blog). The language and type-checking rules are the same, but the defaults changed in 6.0 and old flags now fail. Interviewers like to ask about that, so it's covered in question 33. The latest version on npm is 7.0.2, and TypeScript 7.1 reached beta on 20 October 2026.

What TypeScript interviewers actually test

We read all 870 listings on Weekday's frontend developer jobs page and the first 1,000 on its full stack developer jobs page on 27 November 2026. Almost all are in India, led by Bangalore. We counted mentions in titles, skill tags and short summaries.

SkillFrontend listings (of 870)Full stack listings (of 1,000)
React275149
JavaScript15251
TypeScript11263
Angular6959
Next.js4018
Node.js2039

Summaries are only about 200 characters, so treat these as floor numbers: the real share is higher. Two takeaways:

  • TypeScript is usually tested with React. 88 of the 275 React listings also named TypeScript. Expect "type this component" and "fix this type error", not trivia.
  • Angular roles test it by default. Angular is built on TypeScript, so all 69 Angular listings are TypeScript jobs in practice.

Expect several rounds. In a Weekday analysis of 400 top Reddit posts from the last 30 days (Nov 2026), 19 were about interview rounds and assessments. A common loop is a concepts round, a live coding round where you type a function or component, and for seniors, a design round on types, migrations or build speed.

TypeScript interview questions for freshers

1. What is TypeScript, and why do teams use it?

TypeScript is JavaScript with static types. You add types, the compiler checks them, and the output is plain JavaScript. Teams use it to catch bugs before runtime, get better autocomplete and refactor large codebases safely.

2. Does TypeScript run in the browser?

No. Types are removed before the code runs. tsc or a bundler turns .ts into .js. Node.js can now run many .ts files directly by stripping types (on by default since v22.18 and v23.6), but it doesn't type-check them, so you still run tsc for that (Node.js docs).

3. What are the basic types?

string, number, boolean, bigint, symbol, null, undefined, arrays, tuples and object types, plus any, unknown, never and void.

let name: string = "Asha";
let scores: number[] = [72, 88];
let pair: [string, number] = ["age", 24];

4. any vs unknown vs never?

any turns checking off. unknown accepts anything but makes you narrow it before use. never means no value is possible, like a function that always throws.

function parse(input: unknown): string {
  if (typeof input === "string") return input.trim(); // OK after narrowing
  throw new Error("Expected a string");
}

5. interface vs type?

Both describe object shapes. An interface can be extended and merged with another declaration of the same name. A type alias can also name unions, tuples and mapped or conditional types. A common rule: interfaces for object shapes, types for everything else. Consistency matters more than the choice.

6. What is type inference?

TypeScript works out types from values. let count = 0 is a number without an annotation. Annotate function parameters and public APIs, and let inference handle the rest.

7. What are union and intersection types?

A | B means either one. A & B means both at once.

type Id = string | number;
type Timestamps = { createdAt: Date };
type User = { name: string } & Timestamps;

8. Optional, readonly, ?. and ??

email?: string may be missing. readonly id: string can't be reassigned. user?.address?.city stops at null or undefined. value ?? "N/A" uses the fallback only for null or undefined, while || also replaces 0 and "".

9. Enum or union of string literals?

Enums create a runtime object. A union like "active" | "paused" costs nothing at runtime. Node's type stripping and the erasableSyntaxOnly flag reject enums, so many teams now use unions or as const objects.

const Status = { Active: "active", Paused: "paused" } as const;
type Status = (typeof Status)[keyof typeof Status]; // "active" | "paused"

10. How do you type a function?

Type the parameters and, for public functions, the return value. Use ? for optional parameters, defaults where useful, and a function type for callbacks: type Handler = (e: MouseEvent) => void. Use overloads when different inputs return different types.

11. What do as and ! do?

as tells the compiler to treat a value as a type. ! says a value isn't null or undefined. Neither checks anything at runtime, so both can hide bugs. Prefer narrowing.

12. What is tsconfig.json, and what does strict do?

It's the project config: which files to check, the target JavaScript version, the module system and which checks to run. strict turns on a group of checks, like strictNullChecks and noImplicitAny. Since TypeScript 6.0, strict is on by default.

TypeScript interview questions for 2–5 years

13. What are generics? Show a constraint.

function first<T>(items: T[]): T | undefined {
  return items[0];
}

function getProp<T, K extends keyof T>(obj: T, key: K): T[K] {
  return obj[key];
}

K extends keyof T means you can only pass a key that exists on the object, and the return type follows it.

14. Explain keyof, typeof and indexed access types.

const config = { port: 3000, host: "localhost" };
type Config = typeof config;   // { port: number; host: string }
type ConfigKey = keyof Config; // "port" | "host"
type Port = Config["port"];    // number

15. How does narrowing work? What's a discriminated union?

TypeScript narrows types after checks like typeof, instanceof, in and equality. A discriminated union shares a literal field you can switch on.

type Result =
  | { status: "ok"; data: string[] }
  | { status: "error"; message: string };

function show(r: Result) {
  if (r.status === "ok") return r.data.length; // r is the "ok" member here
  return r.message;
}

16. Write a type guard and an assertion function.

function isString(x: unknown): x is string {
  return typeof x === "string";
}

function assertDefined<T>(x: T): asserts x is NonNullable<T> {
  if (x == null) throw new Error("Missing value");
}

Since TypeScript 5.5, simple predicates are inferred, so list.filter((x) => x !== undefined) narrows on its own.

17. Which utility types do you use most?

Partial, Required, Readonly, Pick, Omit, Record, ReturnType, Parameters, Awaited and NonNullable.

type User = { id: string; name: string; email: string };
type UserUpdate = Partial<Omit<User, "id">>; // every field optional, no id

18. How do you make a switch exhaustive?

function label(r: Result): string {
  switch (r.status) {
    case "ok": return "Done";
    case "error": return "Failed";
    default: {
      const unreachable: never = r; // errors if a new status is added
      return unreachable;
    }
  }
}

19. What does satisfies do?

It checks that a value matches a type without widening the value's own type.

type Route = { path: string; auth: boolean };

const routes = {
  home: { path: "/", auth: false },
  admin: { path: "/admin", auth: true },
} satisfies Record<string, Route>;

routes.admin.path; // keys stay known: "home" | "admin"

20. How do you type React props, state and events?

type ButtonProps = { label: string; onClick: () => void; disabled?: boolean };

function Button({ label, onClick, disabled = false }: ButtonProps) {
  return <button onClick={onClick} disabled={disabled}>{label}</button>;
}

const [user, setUser] = useState<User | null>(null);
const [query, setQuery] = useState("");
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => setQuery(e.target.value);

21. How do you type async code?

An async function returns Promise<T>, and Awaited<T> unwraps it. res.json() gives you any, so type it at the boundary and validate it in production (see question 30).

async function getUser(id: string): Promise<User> {
  const res = await fetch(`/api/users/${id}`);
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return (await res.json()) as User;
}

22. What are .d.ts files and @types packages?

Declaration files describe types for JavaScript code. @types/* packages add types for libraries that don't ship their own. Use declare module "lib-name" for an untyped module. Note: since 6.0, types defaults to [], so list global types you need, like "types": ["node"].

23. What is structural typing? What's an excess property check?

TypeScript compares shapes, not names. Extra properties are fine when you pass a variable, but a fresh object literal is checked strictly.

type Point = { x: number; y: number };
const p3 = { x: 1, y: 2, z: 3 };
const a: Point = p3;                   // OK
const b: Point = { x: 1, y: 2, z: 3 }; // Error: 'z' does not exist in type 'Point'

24. ESM vs CommonJS, and what is import type?

import type { User } from "./types" is removed completely from the output. With verbatimModuleSyntax, TypeScript keeps imports as written, so type-only imports must say type. Node's type stripping needs this. Use "module": "nodenext" for Node and "moduleResolution": "bundler" for apps built with Vite or webpack. The old node10 resolution was deprecated in 6.0 and is an error in 7.0.

25. Index signature, Record or Map?

{ [key: string]: number } and Record<string, number> type plain objects. A lookup returns number even when the key is missing, unless you turn on noUncheckedIndexedAccess, which makes it number | undefined. Use a Map when keys are added and removed at runtime.

Senior TypeScript interview questions

26. Explain conditional types and infer.

type ElementType<T> = T extends (infer U)[] ? U : T;
type A = ElementType<string[]>; // string

type Unwrap<T> = T extends Promise<infer V> ? V : T;
type B = Unwrap<Promise<number>>; // number

When T is a bare type parameter, conditional types distribute over unions, so ElementType<string[] | number[]> is string | number.

27. Write a mapped type with key remapping.

type Getters<T> = {
  [K in keyof T as `get${Capitalize<string & K>}`]: () => T[K];
};

type UserGetters = Getters<{ name: string; age: number }>;
// { getName: () => string; getAge: () => number }

28. What is variance, and why are callback parameters checked "backwards"?

With strictFunctionTypes, function parameters are contravariant. A handler that accepts any Animal can be used where a Dog handler is expected, but not the other way round. Methods declared with method syntax stay bivariant for compatibility. You can mark variance on type parameters with in and out.

29. How do you stop mixing up two string IDs?

Use branded types, so a UserId can't be passed where an OrderId is expected.

type UserId = string & { readonly __brand: "UserId" };
type OrderId = string & { readonly __brand: "OrderId" };

const toUserId = (s: string) => s as UserId;
function getUser(id: UserId) { /* ... */ }

getUser(toUserId("u_42"));      // OK
// getUser("o_17" as OrderId); // Error

30. Types are erased. How do you keep an API safe at runtime?

Validate data where it enters your app (API responses, forms, env vars) with a schema library like Zod or Valibot, and infer the type from the schema. One source of truth, checked at runtime.

import { z } from "zod";

const UserSchema = z.object({ id: z.string(), name: z.string() });
type User = z.infer<typeof UserSchema>;

const user = UserSchema.parse(await res.json()); // throws on bad data

31. How would you migrate a large JavaScript codebase to TypeScript?

Turn on allowJs and checkJs, then rename files a folder at a time. Type the edges first: API clients, shared utilities, data models. Start with loose settings and turn strict checks on one by one. Block new any with a lint rule, and track the error count in CI so it only goes down.

32. Type-checking is slow in a monorepo. What do you do?

Split it with project references and build with tsc -b. Use incremental builds and skipLibCheck. Find hot spots with --extendedDiagnostics and --generateTrace, then simplify huge unions and deep conditional types. And try TypeScript 7: the TypeScript team reports typical speedups of 8x to 12x on full builds.

33. What changed in TypeScript 6.0 and 7.0?

6.0 (March 2026) was the last release on the old JavaScript codebase. It changed defaults: strict on, module set to esnext, types set to []. It deprecated old options like target: es5, moduleResolution: node, baseUrl and AMD, UMD and SystemJS output. 7.0 is the native Go compiler. It keeps 6.0's defaults and makes those deprecated options hard errors. It shipped without a stable programmatic API, which is planned for 7.1 or later, so tools that call the compiler API may stay on 6.x for now.

34. Standard decorators vs experimentalDecorators?

TypeScript 5.0 added support for standard (TC39) decorators. Many existing NestJS and TypeORM codebases still use the older experimentalDecorators with emitDecoratorMetadata. The two work differently, so check which one a project uses before writing a decorator.

35. Design a type-safe event emitter.

type Events = {
  login: { userId: string };
  logout: undefined;
};

class Emitter<E extends Record<string, unknown>> {
  private handlers: { [K in keyof E]?: Array<(payload: E[K]) => void> } = {};

  on<K extends keyof E>(event: K, fn: (payload: E[K]) => void) {
    (this.handlers[event] ??= []).push(fn);
  }

  emit<K extends keyof E>(event: K, payload: E[K]) {
    this.handlers[event]?.forEach((fn) => fn(payload));
  }
}

const bus = new Emitter<Events>();
bus.on("login", (p) => console.log(p.userId)); // p is { userId: string }
// bus.emit("login", { id: "1" });             // Error: wrong payload

Interviewers want to see the event name drive the payload type through generics and indexed access.

A 2-week TypeScript interview prep plan

DaysFocusDo this
1–2BasicsTurn on strict in a small JS project and fix every error
3–4Unions and narrowingModel an API result as a discriminated union with an exhaustive switch
5–6Generics and utility typesWrite getProp, pick and a typed groupBy
7–8React with TypeScriptBuild a typed form with props, state, events and a custom hook
9–10Runtime safetyValidate an API response with a schema and infer the type
11–12Advanced typesWrite a conditional type with infer and a mapped type with key remapping
13–14Mock roundsAnswer questions 26–35 out loud; try TypeScript 7 on your project

Free tool: Paste a job description into Weekday's Interview Question Predictor to see which questions that role is likely to ask.

Find frontend roles that use TypeScript

Weekday lists 870+ frontend developer jobs, with 201 added in the past week. Filter by city, work mode and experience, and apply with your updated resume.

Browse frontend developer jobs →

Frequently asked questions

What are the most asked TypeScript interview questions?

any vs unknown, interface vs type, generics with constraints, narrowing and discriminated unions, utility types like Partial and Omit, the satisfies operator, and how to type React props, state and events.

What is the latest version of TypeScript?

TypeScript 7.0.2 is the latest version on npm. TypeScript 7.0, the native compiler, was released on 8 July 2026, and TypeScript 7.1 reached beta on 20 October 2026.

Do frontend jobs in India need TypeScript?

Many do. On 27 November 2026, 112 of 870 frontend listings on Weekday named TypeScript in their title, tags or short summary, and 88 of the 275 React listings did. These are floor numbers, since we only read short summaries.

How long does it take to prepare for a TypeScript interview?

About two weeks if you already know JavaScript well. Spend the first week on types, narrowing and generics, and the second on React with TypeScript, advanced types and mock rounds.

Is TypeScript 7 a different language?

No. TypeScript 7 checks code the same way as 6.0 but runs on a new native compiler that's often about 10 times faster. It also turns 6.0's deprecated options into errors.

Sources

  1. Weekday frontend developer jobs and full stack developer jobs (27 Nov 2026; all 870 frontend and the first 1,000 full stack listings read for skill counts)
  2. TypeScript blog: Announcing TypeScript 7.0 (8 Jul 2026)
  3. TypeScript blog: Announcing TypeScript 7.0 Beta (21 Apr 2026), for 6.0 defaults and deprecations
  4. npm: typescript package (latest 7.0.2; 7.1.0-beta on 20 Oct 2026)
  5. Node.js docs: TypeScript type stripping
  6. Weekday analysis of 400 top Reddit posts from the last 30 days (Nov 2026)

Latest Articles

Browse Articles
Use AI to find jobs and apply

Stop manually filling job applications. Use AI to auto-apply to jobs

Browse jobs now