TypeScript18 min read

TypeScript Interview Questions: 25 Questions for Developers

25 core TypeScript interview questions covering interface vs type, generics, utility types, mapped types, discriminated unions, type guards, and strict mode.

Pairlet TeamPublished: 2026-09-08

TypeScript is the standard for modern web application engineering. Evaluating a developer's TypeScript skills requires assessing their mastery of the compile-time type system, type safety patterns, and generic utilities.

1. type Alias vs interface

  • interface: Best for object shapes and class contracts. Supports declaration merging (re-opening interfaces across files).
  • type: Alias for any type (primitives, unions, tuples, functions, objects). Does not support declaration merging.
typescriptPairlet Snippet
interface User {
  id: string;
  name: string;

type UserWithRole = User & { role: "admin" | "member" }; ```

2. Discriminated Unions (Tagged Unions)

Discriminated unions use a common literal property key to enable exhaustive type checking by the compiler.

typescriptPairlet Snippet
type NetworkState =
  | { status: "loading" }
  | { status: "success"; data: string[] }

function renderState(state: NetworkState) { switch (state.status) { case "loading": return "Loading..."; case "success": return Data items: ${state.data.join(", ")}; case "error": return Error: ${state.error.message}; } } ```

3. Built-in Utility Types

  • Partial: Makes all properties optional.
  • Required: Makes all properties required.
  • Readonly: Makes all properties readonly.
  • Pick: Selects a subset of properties K from T.
  • Omit: Removes properties K from T.
  • Record: Constructs an object type with keys K and values T.

4. Custom Type Guards (is Keyword)

Type guards provide runtime checks that narrow types within conditional blocks.

typescriptPairlet Snippet
function isString(val: unknown): val is string {
  return typeof val === "string";

function processInput(input: unknown) { if (isString(input)) { console.log(input.toUpperCase()); // TypeScript knows input is string } } ```

5. unknown vs any vs never

  • any: Disables all type checking. Avoid in production code.
  • unknown: Type-safe counterpart to any. Requires type checking before property access or invocation.
  • never: Represents values that can never occur (e.g. function that throws or infinite loop).

---

Practice TypeScript Interviews Live Evaluate TypeScript candidates in a real-time collaborative Monaco environment with instant compilation. [Create a free Pairlet interview room](https://www.pairlet.dev/interview/new).

Frequently Asked Questions

What is the key difference between type aliases and interfaces in TypeScript?

Interfaces support declaration merging and are optimized for object shape extension. Type aliases are more versatile, supporting unions, primitives, tuples, and mapped types.

Practice Relevant Coding Problems
Practice Live Coding

Conduct Live Coding Interviews with Zero Friction

No candidate sign-up required. Create an instant room, share the link, and code together in real time with shared code execution.

Related Articles