🎯

mirror-types

🎯Skill

from marius-townhouse/effective-typescript-skills

VibeIndex|
What it does

Mirrors external types locally to prevent tight coupling and isolate code from external type changes.

πŸ“¦

Part of

marius-townhouse/effective-typescript-skills(83 items)

mirror-types

Installation

Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills --all
Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills -s prefer-unknown-over-any exhaustiveness-checking
Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills -a opencode claude-code
Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills -l
git cloneClone repository
git clone https://github.com/marius-townhouse/effective-typescript-skills.git
πŸ“– Extracted from docs: marius-townhouse/effective-typescript-skills
1Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

Use when depending on external types. Use when avoiding tight coupling. Use when external types might change. Use when building adapters. Use when types are only used internally.

Overview

# Mirror Types to Sever Dependencies

Overview

When you depend on types from external packages, changes to those types can break your code. Mirroring types - creating your own local copies of external types - severs this dependency. This is useful when you only need a subset of external types or when you want to insulate yourself from external changes.

When to Use This Skill

  • Depending on external types
  • Avoiding tight coupling to external packages
  • External types might change frequently
  • Building adapters or wrappers
  • Types are only used internally

The Iron Rule

Mirror external types when you want to sever dependencies. Define only the subset you need, insulated from external changes.

Example

```typescript

// BAD: Direct dependency on external type

import { ExternalUser } from 'external-library';

interface MyService {

processUser(user: ExternalUser): void;

}

// If ExternalUser changes, your code breaks

// GOOD: Mirror the type

interface User {

id: string;

name: string;

email: string;

}

interface MyService {

processUser(user: User): void;

}

// Adapter converts external to internal type

function adaptExternalUser(external: ExternalUser): User {

return {

id: external.id,

name: external.name,

email: external.email,

};

}

```

Reference

  • Effective TypeScript, 2nd Edition by Dan Vanderkam
  • Item 70: Mirror Types to Sever Dependencies

More from this repository10

🎯
tsdoc-comments🎯Skill

Generates TypeScript documentation comments (TSDoc) to explain public APIs, complex types, and provide comprehensive code documentation with IDE tooltips.

🎯
async-over-callbacks🎯Skill

Transforms callback-based asynchronous code into clean, readable async/await patterns for better type flow and error handling.

🎯
module-by-module-migration🎯Skill

Guides developers through systematic TypeScript module migration, breaking down complex refactoring into manageable, incremental steps.

🎯
create-objects-all-at-once🎯Skill

Efficiently initializes multiple TypeScript objects simultaneously using concise object literal syntax and spread operators.

🎯
functional-constructs-types🎯Skill

Explores advanced functional programming techniques and type system features in TypeScript for creating more robust and expressive code.

🎯
ts-check-jsdoc-experiment🎯Skill

Enables gradual TypeScript type checking in JavaScript files using @ts-check and JSDoc annotations without full conversion.

🎯
code-gen-independent🎯Skill

Generates JavaScript code despite TypeScript type errors and demonstrates that TypeScript types are erased at runtime, requiring alternative type checking strategies.

🎯
ts-js-relationship🎯Skill

Explains TypeScript's relationship to JavaScript, highlighting how it adds static typing and catches errors before runtime while remaining fully compatible with JavaScript code.

🎯
type-safe-monkey-patching🎯Skill

Enables type-safe runtime extension of global objects and DOM elements in TypeScript without sacrificing type checking or using `as any`.

🎯
type-display-attention🎯Skill

Displays and simplifies complex TypeScript types to improve IDE readability and developer experience.