00

Guide

TYPESCRIPT INTERVIEW Qs

Technical questions and model answers for interviewing TypeScript developers. Covers type system, generics, unions, type guards, and utility types.

Last updated: May 2026

01

Explain the difference between type and interface

interface defines the shape of an object and supports declaration merging — multiple declarations with the same name are automatically combined. type is more versatile as an alias: it can name primitives, unions, intersections, and tuples. Extension uses extends for interfaces and intersection (&) for types. interfaces are often preferred for public library APIs.

02

What are the benefits of generics? Give a concrete example

Generics let you write reusable code while preserving type safety. Example: function identity<T>(arg: T): T { return arg; }. T is inferred to a concrete type, so type information isn't lost like with any. In React, generics are used everywhere: useState<T>, Promise<T>, array methods, and more.

03

What is a Discriminated Union and how do you use it?

A Discriminated Union combines multiple types that share a common literal property (the discriminant). Example: type Shape = { kind: 'circle'; radius: number } | { kind: 'square'; side: number };. By checking kind in a switch or if statement, you safely access each type's unique properties without explicit type guards. Widely used for Redux action types and API result types.

04

Explain the types of type guards and their use cases

There are three main kinds of type guards. (1) typeof operator — narrows primitives like string, number, and boolean. (2) instanceof operator — distinguishes class instances. (3) User-defined type guards — custom functions returning arg is Type to narrow complex types. They guarantee types at runtime and communicate type information to the compiler.

05

Where do you use Utility Types like Partial, Pick, Omit, and Record?

Utility Types let you derive new types from existing ones, keeping your code DRY. Partial<T> makes all properties optional, useful for form update objects. Pick<T, K> extracts only needed properties for display types. Omit<T, K> excludes specific properties for DTOs. Record<K, T> is handy for mapping types and configuration objects.

06

What are the benefits and caveats of enabling strict mode?

Enabling strict: true activates noImplicitAny, strictNullChecks, strictFunctionTypes, and more, dramatically improving type safety. strictNullChecks in particular drastically reduces runtime errors from undefined and null. The caveat: migrating existing JavaScript projects can produce a large number of type errors, so it's practical to enable gradually or start with strictNullChecks.

07

Contact

Looking for a TypeScript Developer?

I can support your technical interviews, advise on hiring, or join directly as your TypeScript engineer.

TypeScript Developer Interview Questions | Code Your Reality