mirror-types
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.
How do I install this agent skill?
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill mirror-typesIs this agent skill safe to install?
- Gen Agent Trust Hubpass
This skill provides architectural guidelines for TypeScript development, specifically teaching how to decouple code from external packages by mirroring types. It contains no executable scripts, network operations, or sensitive file access.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerpass
1 file scanned · No issues
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
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
// 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
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/marius-townhouse/effective-typescript-skills/mirror-types">View mirror-types on skillZs</a>