October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

TypeScript Interface vs. Type: A Clear Interview Answer

Both TypeScript interfaces and type aliases can describe objects. Learn the distinctions—merging, extension, unions, and tuples—and give a concise interview answer.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

interface and type can both describe object shapes, but they are not interchangeable in every situation. An interface is a named object contract that can be extended and declaration-merged; a type alias can name an object shape too, and can also name unions, tuples, primitives, intersections, and other type expressions. In an interview, explain those differences, then say you choose based on the capability and intent—not because one syntax is universally better.

How do interface and type overlap?

Both constructs can give a name to an object shape. For an ordinary object contract, either can describe properties and their types:

interface User {
  id: number;
  name: string;
}

type UserAlias = {
  id: number;
  name: string;
};

That overlap is why the interview answer should not claim that interfaces are for objects and aliases are not. The practical distinction is what else each declaration can do.

What can a type alias represent that an interface declaration cannot?

A type alias names a type expression, not just an object shape. It can name unions, tuples, primitive types, intersections, and object shapes. For example, a result that may be either a success or a failure is naturally a union:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
type Result = Success | Failure;

An interface declaration cannot directly stand for that union. The TypeScript Handbook describes the broader range of forms that aliases can name in its discussion of advanced types; unions and intersections are also covered in the Handbook’s union and intersection reference.

How do extends and intersections differ?

Interfaces compose with extends; type aliases can compose types with the intersection operator &. These mechanisms are not equivalent when property declarations conflict. Interface extension checks that inherited members are compatible, while an intersection requires the resulting value to meet both sets of requirements. The latter can leave a property with an impossible type.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
  • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem
interface HasName {
  value: string;
}

interface HasNumber {
  value: number;
}

// Rejected: inherited value declarations conflict.
interface Combined extends HasName, HasNumber {}

// Combines both requirements for value.
type CombinedAlias = HasName & HasNumber;

Here the intersection does not simply choose one property’s type: a value would have to satisfy both string and number for value. The Handbook explains the difference between interface extension and intersections in its object types reference.

What is declaration merging?

When compatible interface declarations have the same name in the same scope, TypeScript can merge them into one interface. A type alias cannot be reopened by declaring another alias with the same name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
interface Settings {
  theme: string;
}

interface Settings {
  compact: boolean;
}

// Settings now has both theme and compact.

This is distinct from extends: merging combines separate declarations bearing the same name, while extension defines a new interface in relation to an existing type. The official declaration merging reference describes the behavior and its rules.

Which one should you choose?

Need Natural choice Reason
An extensible object contract interface It supports extends and compatible declaration merging.
A union, tuple, primitive alias, or another type expression type A type alias can name these forms; an interface declaration cannot directly represent a union or tuple.
A regular object shape with no special requirement Either Both can describe object shapes; follow your team’s conventions and intended extension behavior.

The TypeScript Handbook presents interfaces as a good fit for extensible object shapes and aliases as useful when a union or tuple is required. Treat that as practical guidance, not a rule that makes one form universally superior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A concise interview response

“Both interface and type can describe object shapes. Interfaces support extension and declaration merging, while a type alias can name a wider range of type expressions, including unions and tuples. I’d use an interface for an extensible object contract and a type alias when I need a union or another expression; for a simple object shape, I’d follow the project’s convention.”

The question is phrased on interview-question pages as “Differences between type alias and interface.” That wording identifies it as an interview prompt, not evidence about how often employers ask it. See the ITLead interview question.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.