Interview Q&A · questions with model answers
TypeScript Developer Interview Questions
Part of the study plan for: Frontend Engineer · Full Stack Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked Which built-in utility types do you use most, and what do they do?
Common ones: Partial<T>, Required<T>, Readonly<T>, Pick<T, K>, Omit<T, K>, Record<K, V>, Exclude<U, X>, Extract<U, X>, NonNullable<T>, ReturnType<F>, Parameters<F>, Awaited<T> and NoInfer<T> (5.4).
-
Most asked What does the `satisfies` operator do and how does it differ from a type annotation?
satisfies (TypeScript 4.9) checks that an expression conforms to a type without changing the expression's inferred type, so you get validation and keep precise literal types. An annotation (const x:…
-
Most asked Should you use enums or union types in TypeScript?
Many teams prefer string literal unions (optionally derived from an as const object) over enums: unions are erased at compile time, work with structural typing and plain strings, and are supported…
-
Most asked Which `tsconfig` strictness options matter and what do they catch?
strict: true enables strictNullChecks, noImplicitAny, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, useUnknownInCatchVariables, alwaysStrict and noImplicitThis. Extra…
-
Most asked What are type assertions (`as`) and the non-null assertion (`!`), and why should you use them sparingly?
value as T tells the compiler to treat a value as T, and value! asserts it isn't null/undefined. Neither does anything at runtime; if you're wrong, you get runtime errors the compiler could have…
-
Most asked What are intersection types and how do they differ from interface extension?
Intersection types (A & B) combine types so the value must satisfy all of them. Interface extends also combines but reports conflicts eagerly, whereas conflicting intersection members can silently…
-
How do module systems (ESM vs CommonJS) interact with TypeScript settings?
module and moduleResolution control emitted module syntax and how imports are resolved. For Node, use module: "nodenext" (which respects package.json type and exports); for bundled frontends, use…
-
How do `tsc`, esbuild, SWC and Babel differ for TypeScript builds?
tsc type-checks and emits JavaScript and declaration files; esbuild, SWC and Babel strip types extremely fast without type checking. Modern setups transpile with a fast tool (Vite, tsx, Next.js/SWC)…
-
What's the difference between an optional property (`x?: T`) and `x: T | undefined`?
x?: T means the property may be absent (and, by default, also explicitly undefined); x: T | undefined means the property must be present but may hold undefined. With exactOptionalPropertyTypes, x?:…
-
How do TypeScript access modifiers compare with JavaScript private fields?
private/protected in TypeScript are compile-time only (the property exists and is accessible at runtime), while JavaScript #private fields are enforced by the runtime. TypeScript supports both.
-
When would you use an abstract class versus an interface in TypeScript?
Use an interface for a pure type contract (no runtime footprint, multiple implementation); use an abstract class when you need shared implementation, constructor logic or protected members, and you…
-
What's the difference between `// @ts-ignore` and `// @ts-expect-error`?
Both suppress the error on the next line, but @ts-expect-error itself errors if there's no error to suppress, so stale suppressions are detected when the underlying issue is fixed.
-
How do you type JSON values or recursive structures?
Use recursive type aliases, e.g. type Json = string | number | boolean | null | Json[] | { [key: string]: Json }, and recursive interfaces for trees (interface TreeNode { children: TreeNode[] }).
-
What's the difference between `object`, `Object` and `{}` types?
object means any non-primitive value; {} means any value except null and undefined (including primitives); Object is similar to {} and should be avoided. Use Record<string, unknown> for 'any plain…
-
Should you use namespaces in modern TypeScript?
Generally no for application code: ES modules provide scoping and organization. Namespaces remain useful for declaration files (describing globals or legacy libraries) and for declaration merging…
-
What's the difference between `const`, `readonly` and `as const`?
const prevents reassigning a variable binding; readonly prevents reassigning a property at compile time; as const makes an expression's inferred type deeply readonly with literal types.
-
What's the difference between `string[]`, `Array<string>` and `[string]`?
string[] and Array<string> are identical: arrays of any length containing strings. [string] is a tuple of exactly one string.
-
When should a function accept a union parameter versus using overloads?
Accept a union when the return type doesn't depend on which member is passed; use overloads (or generics/conditional types) when different inputs produce different return types the caller needs to…