ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

TypeScript Interview Questions and Answers

TypeScript is now expected in most modern frontend roles. Here are the questions interviewers ask and how to answer them.

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

any opts out of type checking (avoid it). unknown is the type-safe any — you must narrow before using it. never is a value that can't occur, like a function that always throws or an impossible switch branch.

interface vs type — when do you use each?

Both describe object shapes and are often interchangeable. interface can be extended and declaration-merged (good for object shapes and public APIs); type aliases work for anything — unions, tuples, mapped and conditional types.

What are generics?

A type parameter filled in when a function/type is used, so one reusable piece of code stays type-safe across many types instead of falling back to any. Constrain them with `extends`.

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

Name some utility types.

Partial<T> (all optional), Pick<T, K> / Omit<T, K> (keep/remove properties), Record<K, V>, ReturnType<Fn>, Awaited<T>, NonNullable<T>. Derive related types with these instead of duplicating.

What is a discriminated union?

A union whose members share a literal 'tag' field, so switching on that tag narrows to the exact shape. Ideal for state (loading/success/error), Redux actions and API responses.

What does `as const` do?

It freezes a value into its narrowest, readonly literal type — perfect for constant config and deriving union types from data (typeof ARR[number]).

Learn TypeScript properly

The type system, generics, utility & advanced types, and TypeScript with React — a full handbook in the Complete Frontend Kit.

⚡ Get the Complete Frontend Kit → ₹499

Frequently asked questions

Should I use unknown or any?
Prefer unknown and narrow before use. any disables type checking and spreads through your code — avoid it.
Is TypeScript required for frontend jobs now?
Increasingly yes — most modern React codebases use it, and it's commonly tested.

Full kit

Complete Frontend Kit · ₹499

Get it →