typescript-interface-vs-type

Guides choosing between interface and type aliases in TypeScript code.

Updated Aug 16, 2026
One-click install
npx skills add https://github.com/Aveer/skills --skill typescript-interface-vs-type-aveer
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-interface-vs-type
Source: https://github.com/Aveer/skills/tree/main/skills/typescript-interface-vs-type
Command: npx skills add https://github.com/Aveer/skills --skill typescript-interface-vs-type-aveer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript developers often face uncertainty when deciding whether to declare shapes with interface or type, leading to inconsistent codebases, confusing error messages, and slower type checking. ## Core Features & Use Cases - Decision Guidance: Applies the official TypeScript Handbook recommendation to use interface until features from type are required. - Feature Mapping: Lists when type is necessary, including union types, mapped types, conditional types, tuples, and function types. - Extends vs Intersection: Explains why interface extends is preferred over & intersections, with concrete examples showing earlier error detection and better compiler performance. - Use Case: When defining a new Admin object that builds on a User shape, use this Skill to write interface Admin extends User instead of a type intersection, catching incompatible property errors at definition time. ## Quick Start Ask the AI to review your TypeScript type declarations and apply the interface versus type guidelines from this skill.

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 by default for object type definitions, following the official TypeScript Handbook recommendation. Switch to type only when you need unions, mapped types, conditional types, tuples, or function type aliases.

Is interface extends better than type intersection in TypeScript?▼

Interface extends is preferred over the & intersection operator. It raises errors at the definition site for incompatible properties and performs better because interfaces are cached by name while intersections are recomputed on each use.

Can TypeScript interfaces define union types?▼

No, interfaces cannot express union types. Use a type alias for unions such as type Status = 'pending' | 'approved' | 'rejected', as well as for mapped, conditional, and tuple types.

Why does TypeScript not error when intersecting conflicting types?▼

Type intersections defer error detection until the conflicting property is actually accessed, so a definition like Base & { id: string } compiles silently. Interface extends surfaces the incompatibility immediately at the declaration.

Does using interfaces improve TypeScript compiler performance?▼

Yes, interfaces are cached by name so TypeScript computes the type once and reuses it. Intersections are recomputed every time they are used, which slows type checking in codebases with complex type relationships.