.config/opencode/skills/typescript-interface-vs-type/SKILL.md
Guides when to use interface vs type in TypeScript. Use this skill when defining object types, extending types, or choosing between interface and type aliases.
npx skillsauth add klen/dotfiles typescript-interface-vs-typeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use interface until you need features from type.
This is the official TypeScript recommendation from the TypeScript Handbook.
Use interface for:
Use type only when you need:
type Status = 'pending' | 'approved' | 'rejected'type Readonly<T> = { readonly [K in keyof T]: T[K] }type NonNullable<T> = T extends null | undefined ? never : Ttype Point = [number, number]type Handler = (event: Event) => voidinterface extends Over Intersection (&)When extending object types, always prefer interface extends over type intersections.
// Preferred
interface User {
name: string;
}
interface Admin extends User {
permissions: string[];
}
// Avoid
type User = {
name: string;
};
type Admin = User & {
permissions: string[];
};
With interface extends, TypeScript raises errors at the definition
when extending with incompatible properties:
interface Base {
id: number;
}
// Error immediately at definition
interface Extended extends Base {
id: string; // Error: Type 'string' is not assignable to type 'number'
}
With intersections, errors only appear when accessing the incompatible property, making bugs harder to catch:
type Base = {
id: number;
};
// No error at definition
type Extended = Base & {
id: string;
};
// Error only when used
const item: Extended = { id: 'abc' }; // Error appears here, not at type definition
interface extends provides better TypeScript performance:
See TypeScript Performance Wiki for details.
tools
Anti-patterns and mistakes to avoid as a product manager. Use when evaluating leadership behaviors, improving team dynamics, reflecting on management practices, or onboarding new product managers.
development
Guides proper usage of TypeScript's satisfies operator vs type annotations. Use this skill when deciding between type annotations (colon) and satisfies, validating object shapes while preserving literal types, or troubleshooting type inference issues.
development
Guides TypeScript best practices for type safety, code organization, and maintainability. Use this skill when configuring TypeScript projects, deciding on typing strategies, writing async code, or reviewing TypeScript code quality.
tools
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.