Skip to main content
InterviewHubPRO
Section Overview
Q4

Question 4 of 50

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

8%
TypeScript Master (50 Qs)•Part 1: Basic & Foundational TypeScript (Junior / Entry-Level)

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

junior LevelCode ExampleTypeScript

In Simple Words: Both define the shape of objects, but they have key architectural differences:

Featureinterfacetype Alias
Declaration MergingYes (multiple interfaces with same name merge automatically)No (duplicate names throw compile error)
Union & Primitive TypesCannot directly define unions (A | B) or primitivesCan define unions, tuples, primitives (type ID = string | number)
ExtensibilityExtends via extends keywordExtends via intersection operator (&)
Compiler PerformanceSlightly faster cached lookups in older TS compilersEquivalent in modern TS 5.x
Best PracticeIdeal for public API contracts and object schemasIdeal for unions, utility types, and complex mapped/conditional types
typescript
// Interface declaration merging
interface User { name: string; }
interface User { age: number; }
// User now has both: { name: string; age: number; }

// Type union (cannot be done with interface)
type Status = "pending" | "approved" | "rejected";