TypeScript Patterns

SkillDev tools

TypeScript best practices and patterns. Use when writing TypeScript, fixing type errors, or working with generics.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the TypeScript Patterns skill

What this skill tells your AI

The instructions your AI receives, as published by tibsfox/gsd-skill-creator in project-claude/skills/typescript-patterns/SKILL.md and read by ahel’s review.

Type vs Interface

Use CasePrefer
Object shapeinterface
Union typestype
Extending shapesinterface
Intersectiontype
Tuple/primitivestype

Key Patterns

Discriminated Unions — model state with tagged types:

type Result<T> = { ok: true; value: T } | { ok: false; error: Error };

Type Guards — narrow at runtime:

function isUser(obj: unknown): obj is User {
  return typeof obj === 'object' && obj !== null && 'id' in obj;
}

Generic Constraints:

function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] { return obj[key]; }

Utility Types

TypePurpose
Partial<T>All optional
Required<T>All required
Pick<T,K>Select properties
Omit<T,K>Remove properties
Record<K,V>Key-value map
ReturnType<T>Function return type

Avoid

  • any — use unknown and narrow
  • Type assertions (as) — use type guards
  • ! operator — handle null properly
  • Missing return types on complex functions

Signals

GitHub stars
69
Forks
9
Last commit
Jul 2026
Advanced
Catalog kind
skill
Gateway key
typescript-patterns-tibsfox
Source
github.com/tibsfox/gsd-skill-creator