typescript-interface-vs-type

Guides choosing between interface and type aliases in TypeScript code.

Updated Apr 29, 2026
One-click install
npx skills add https://github.com/dev-khoi/AURA-conHack-2026 --skill typescript-interface-vs-type-dev-khoi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-interface-vs-type
Source: https://github.com/dev-khoi/AURA-conHack-2026/tree/main/.opencode/skills/typescript-interface-vs-type
Command: npx skills add https://github.com/dev-khoi/AURA-conHack-2026 --skill typescript-interface-vs-type-dev-khoi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript developers often face uncertainty when deciding whether to declare object shapes with interface or type, leading to inconsistent codebases, confusing compiler errors, and slower type checking. ## Core Features & Use Cases - Decision Guidance: Applies the official TypeScript recommendation to use interface by default and reserve type for unions, mapped types, conditional types, and tuples. - Extends vs Intersection Rules: Explains why interface extends produces earlier, clearer error messages and better compiler performance than & intersections. - Use Case: When defining a new Admin model that builds on a User model, this Skill directs you to write interface Admin extends User so incompatible property overrides fail at the definition site instead of at usage. ## Quick Start Ask the assistant to review your TypeScript type declarations and recommend whether each should be an interface or a type alias.

Frequently Asked Questions about typescript-interface-vs-type

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use interface vs type in TypeScript?▼

Use interface for object type definitions, extending other types, class implementations, and declaration merging. Reserve type for unions, mapped types, conditional types, tuples, and function signatures, following the official TypeScript Handbook recommendation.

Is interface extends better than type intersection in TypeScript?▼

Yes, interface extends is preferred over the & intersection operator. It raises errors at the definition site for incompatible properties and is cached by name, while intersections are recomputed on every use, slowing type checking.

Can TypeScript interfaces express union types?▼

No, interfaces cannot represent union types like 'pending' | 'approved'. Unions require a type alias, which is one of the cases where type is the correct choice over interface.

Why does my intersection type not error at the definition?▼

Intersections with & do not validate conflicting properties at declaration time; errors only surface when the type is used. Switching to interface extends makes TypeScript report incompatible overrides immediately at the definition.

Does using interfaces improve TypeScript compiler performance?▼

Yes, interfaces are cached by name so TypeScript computes them once and reuses the result. Intersections are recomputed each time they are referenced, which slows type checking in complex codebases, per the TypeScript Performance Wiki.