Skip to main content
InterviewHubPRO
HomeTracksSection 1: TypeScript Master (50 Qs)
Section 1 of 6450 Questions (1 Per Page)

TypeScript Enterprise Architecture, Type Systems & Advanced Typings Master Interview Bank

Advanced generic type algebra, conditional types, template literals, type narrowing, distributive types, and decorator metadata.

Curriculum Roadmap & Learning Path

3 Stages
Tip: Click any stage card above to instantly filter the question bank to that topic.3 Connected Milestones
50 of 50 Qs

Part 1: Basic & Foundational TypeScript (Junior / Entry-Level)

15 Questions
1
Junior#TypeScript

What is TypeScript and how does it relate to JavaScript?

TypeScript is a strongly typed programming language developed by Microsoft that builds on JavaScript by adding optional static typing.: Syntactic Superset: Any valid JavaScript code is automatically valid TypeScript code (.js files can be renamed to .ts) • Compile-Time Only: Browsers and Node.js cannot execute TypeScript directly.

2
Junior#TypeScript

What are Primitive Types vs Object Types in TypeScript?

Primitive Types: Built-in immutable JavaScript primitives: string, number, boolean, bigint, symbol, null, undefined • Object Types: Non-primitive structures: object, arrays (number[]), interfaces, classes, tuples, and functions • Convention Note: Always use lowercase primitive types (string, number, boolean).

3
JuniorCode#TypeScript

Compare `any`, `unknown`, and `never`.

Type Meaning Type Safety Operations Allowed.

4
JuniorCode#TypeScript

What is the difference between `type` alias and `interface`?

Both define the shape of objects, but they have key architectural differences.

5
JuniorCode#TypeScript

How do Function Signatures and Return Types (`void` vs `never`) work?

void: Indicates a function completes execution without returning a value (returns undefined implicitly) • never: Indicates a function never finishes successfully—either it throws an uncaught exception or enters an infinite loop (while(true)).

6
Junior#TypeScript

Why does modern TypeScript favor String Union Types over Enums?

Numeric and standard Enums in TypeScript generate real JavaScript code during compilation (creating reverse-mapping object tables).: Enums: Pollute the compiled bundle with runtime object overhead and can produce unsafe numeric assignments (enum Status { Active, Inactive }).

7
JuniorCode#TypeScript

What are Tuples and `as const` assertions?

Tuple: An array with a fixed length and known types at specific indices: [string, number] • as const (Const Assertion): Tells the compiler to infer the most specific, literal, readonly type possible.

8
Senior#TypeScript

What is the difference between Type Assertions (`as`) and Type Casting?

Type Casting in languages like C# or Java converts data representations at runtime (e.g. converting float bytes to integer) • Type Assertion (as Type) in TypeScript is purely a compile-time instruction telling the compiler: "Trust me, I know the type better than you.

9
JuniorCode#TypeScript

What is Structural Typing (Duck Typing)?

TypeScript uses structural typing, not nominal typing. Two types are considered identical if they have the same structure (shape), regardless of their declared names.

10
JuniorCode#TypeScript

What are Generics and why are they necessary?

Generics allow you to write reusable, type-safe functions, classes, and interfaces that work over a variety of types rather than a single fixed type, capturing the argument type dynamically.

11
JuniorCode#TypeScript

How do Generic Constraints (`extends`) work?

By default, generic T can be anything. Using T extends Shape constrains T to types that contain specific required properties.

12
Most AskedJuniorCode#TypeScript

What is the `keyof` operator and Indexed Access types?

keyof T: Produces a union of all property keys of type T • T[K] (Indexed Access): Extracts the type of a specific property K on type T.

13
JuniorCode#TypeScript

What are Discriminated Unions (Tagged Unions)?

A pattern where multiple object types share a common, unique literal property (the "discriminant" or "tag"). TypeScript automatically narrows the union inside a switch or if block.

14
JuniorCode#TypeScript

How do Type Narrowing and Custom Type Guards (`is`) work?

TypeScript automatically narrows types within conditional branches using: typeof x === 'string' • x instanceof Date • 'property' in obj.

15
Junior#TypeScript

What are the essential flags in `tsconfig.json`?

"strict": true: Enables all strict type-checking options (the single most important flag) • "target": "ES2022": Target ECMAScript version for output JS • "module": "NodeNext": Module system for code generation • "noImplicitAny": true: Raises an error on any variable whose type defaults to any.

Part 2: Advanced Type System & Metaprogramming (Mid-Level)

15 Questions
16
JuniorCode#typescript#Advanced Type System

What are Conditional Types and Distributive Conditional Types?

Conditional types choose one of two possible types based on a subtyping relationship: T extends U ? X : Y When a conditional type operates on a generic union type (a "naked" type parameter), it automatically distributes over each union member.

17
MidCode#typescript#Advanced Type System

How does the `infer` keyword work in conditional types?

infer allows you to declare a type variable inside the condition to extract or unwrap an unknown subtype.

18
JuniorCode#typescript#Advanced Type System

What are Mapped Types and Key Remapping (`as`)?

Mapped types build new types by transforming each property in an existing type.

19
JuniorCode#Components

What are Template Literal Types?

Template literal types bring JavaScript template string interpolation syntax directly into the type system.

20
MidCode#typescript#Advanced Type System

Explain Standard Utility Types: `Partial`, `Required`, `Readonly`, `Record`.

PartialT: Makes all properties optional (?) • RequiredT: Removes all optional modifiers (-?) • ReadonlyT: Adds readonly to all properties • Record: Constructs an object type with property keys K and value type T.

21
MidCode#typescript#Advanced Type System

Explain Filtering Utility Types: `Pick`, `Omit`, `Exclude`, `Extract`.

Pick: Constructs a type by picking specific keys K from object T • Omit: Constructs a type by omitting keys K from object T • Exclude: Excludes from union T all members assignable to U • Extract: Extracts from union T all members assignable to U.

22
JuniorCode#TypeScript

What is the `satisfies` operator in TypeScript 4.9+?

Before satisfies, you had a dilemma: If you annotated const palette: Colors = { .. • If you omitted the annotation const palette = { .

23
MidCode#typescript#Advanced Type System

How do you implement a Deep Partial or Deep Readonly type?

Standard PartialT is shallow (only makes top-level keys optional). Using recursive conditional types, we can make every nested level optional.

24
JuniorCode#typescript#Advanced Type System

What are Overloaded Function Signatures?

Function overloading allows a function to accept different combinations of parameters and return different types. You define multiple public function signatures followed by a single private implementation.

25
JuniorCode#typescript#Advanced Type System

What are Ambient Declarations and `.d.ts` files?

Ambient declarations describe the shape of existing JavaScript code that has no built-in types (e.g., globals on window, external C-modules, or legacy npm packages). Defined using the declare keyword in .d.ts files. They contain zero executable JavaScript—only type definitions.

26
JuniorCode#TypeScript

What are `const` Type Parameters (TypeScript 5.0+)?

In TypeScript 5.0, you can prefix a generic parameter with const to enforce that calls automatically infer as const literal types without forcing callers to write as const manually!

27
Junior#TypeScript

What is Variance in TypeScript (Covariance vs Contravariance)?

Variance describes how subtyping of complex types relates to subtyping of their component types: Covariance (Output positions): If Dog extends Animal, then Dog[] extends Animal[], and () => Dog extends () => Animal • Contravariance (Input/Parameter positions): Function parameters are contravariant under strictFunctionTypes.

28
JuniorCode#typescript#Advanced Type System

What is the `asserts` condition operator?

The asserts keyword defines an assertion function. If the function returns without throwing, TypeScript narrows the type of the argument for all subsequent lines in that scope.

29
JuniorCode#typescript#Advanced Type System

What are Excess Property Checks?

TypeScript normally allows passing an object with extra properties where fewer properties are expected (structural typing). However, when passing an object literal directly, TypeScript triggers Excess Property Checks to prevent typos.

30
MidCode#TypeScript

How do ECMAScript Stage 3 Decorators work in TypeScript 5.x?

TypeScript 5.0 adopted the official ECMAScript standard Decorators (replacing the legacy experimentalDecorators flag). Decorators are functions applied to classes, methods, accessors, and fields to wrap or replace them.

Part 3: Enterprise Architecture, Compiler Internals & Performance (Senior / Staff)

20 Questions
31
SeniorCode#Forms#Performance

Explain the TypeScript Compiler Architecture and Compilation Pipeline.

The tsc compiler operates across five sequential stages: Scanner: Reads source text and converts characters into Tokens • Parser: Consumes tokens and builds the Abstract Syntax Tree (AST) • Binder: Traverses the AST and connects declarations to Symbols (scoping and symbol table) • Checker: The core of TypeScript.

32
SeniorCode#Forms#Performance

How do you implement Nominal Typing (Branded Types) in TypeScript?

Because TypeScript is structurally typed, a UserId (string) and an OrderId (string) are completely interchangeable, leading to catastrophic runtime bugs where an order ID is passed into a user deletion function! Branded Types attach a unique compile-time phantom property.

33
Senior#Forms#Performance

How do you optimize TypeScript compilation speed in massive enterprise codebases?

skipLibCheck: true: Skips type-checking of all .d.ts declaration files inside node_modules (saves up to 50% compilation time) • incremental: true: Saves compilation state to a .tsbuildinfo cache file for fast incremental builds.

34
Senior#Forms#Performance

What are Project References and Composite Projects?

In a monorepo with 50 packages, running tsc across all 50 packages in a single run exhausts memory and takes minutes.

35
SeniorCode#Forms#Performance

How does Runtime Validation (Zod) synchronize with Compile-Time TypeScript?

TypeScript types vanish at runtime and cannot validate incoming API payloads from external users. Zod provides runtime schema validation that automatically infers static TypeScript types using z.infer.

36
SeniorCode#Forms#Performance

How do you build a strongly-typed Event Emitter?

By mapping event names to their payload types, you can enforce that emit and on require exact payload signatures.

37
SeniorCode#Forms#Performance

How do you implement Deep Tuple Reverse using Recursive Conditional Types?

Deep tuple reversal uses recursive conditional types with variadic tuple unpacking and the infer keyword to peel off the first element and append it to the recursively reversed tail. #### Code Example.

38
Senior#Forms#Performance

How do you diagnose and debug slow types in a TypeScript codebase?

Complex recursive conditional types or massive union combinations can freeze tsc.: Run tsc --extendedDiagnostics: Displays total check time, number of types created, and memory usage • Run tsc --generateTrace trace_dir: Generates Chrome DevTools performance traces.

39
Senior#Forms#Performance

What causes the error `Type instantiation is excessively deep and possibly infinite`?

TypeScript caps recursive type evaluations (around 1,000 recursive steps in modern versions) to prevent compiler stack overflows.: Cause: Recursive mapped types lacking a proper base case or operating over circular data structures.

40
Senior#Forms#Performance

Explain TypeScript Module Resolution Modes (`Node16`, `NodeNext`, `Bundler`).

Node16 / NodeNext: Adheres strictly to Node.js ESM rules (requires explicit file extensions in imports like import './utils.js', respects • Bundler: Introduced in TS 5.0 for modern bundlers (Vite, Webpack, Turbopack) that resolve extensions and paths without requiring .js extensions.

41
Senior#Forms#Performance

What is the difference between `declare module` and `declare global`?

declare module "some-package": Augments or provides types for an external npm package • declare global: Augments the top-level global environment (adding properties to window, globalThis, or document) from within a module file.

42
SeniorCode#Forms#Performance

How do you enforce Exhaustive Type Checking in `switch` statements?

Assigning the unhandled case to a never variable guarantees that if a new member is added to a union, the TypeScript compiler will fail until all cases are handled.

43
SeniorCode#Forms#Performance

What is the difference between Method Signatures and Property Signatures in Interfaces?

```typescript interface Comparer { method(a: number): void; // Bivariant (under strictFunctionTypes) property: (a: number) => void; // Contravariant (strictly checked) }.

44
Senior#Forms#Performance

What is `exactOptionalPropertyTypes`?

By default with strict: true, an optional property foo?: string allows assigning foo = undefined. Enabling "exactOptionalPropertyTypes": true enforces that an optional property must either be present with the exact type (foo: "hello") or completely omitted ({}), but never explicitly assigned undefined.

45
SeniorCode#Routing#Forms

How do you implement a Type-Safe Router or Path Parameter Parser?

Using recursive template literal types, we can infer dynamic URL parameters from a route string.

46
Most AskedSeniorCode#Forms#Performance

What is the `noUncheckedIndexedAccess` flag and why is it essential?

In standard TypeScript.

47
Senior#Forms#Performance

How do you write an Abstract Syntax Tree (AST) Transformer in TypeScript?

TypeScript provides the ts.transform API allowing compiler plugins to inspect and modify AST nodes during compilation: Walks the AST using ts.visitEachChild • Detects specific nodes (e.g. ts.isCallExpression).

48
Senior#Forms#Performance

What is the recommended strategy for migrating a 500k-line legacy JS codebase to strict TS?

Enable TypeScript in loose mode: Set "allowJs": true, "checkJs": false, "strict": false • Setup CI with --noEmit: Type check files without generating build assets • Migrate leaf files first: Convert utilities and core constants (.js -> .ts).

49
Senior#Forms#Performance

How do you write Type-Safe SQL queries with Kysely or Slonik?

Instead of ORMs that hide SQL or raw strings with zero type checking, type-safe query builders like Kysely use TypeScript's mapped and indexed access types: Database schema is defined as a TypeScript interface • Kysely's query builder autocompletes table and column names and infers the exact return type of SELECT expressions.

50
Senior#Forms#Performance

What are the flagship innovations introduced in TypeScript 5.0 through 5.5+?

TS 5.0: Standard ECMAScript Decorators, const type parameters, multiple config inheritance (extends: [...]) • TS 5.1: Unrelated types for getters and setters, decoupled JSX namespaces for React Server Components • TS 5.2: using declarations (Explicit Resource Management / Disposable pattern).