lang-typescript

Solve type-safety problems in TypeScript code with strict mode and runtime validation.

Updated Nov 4, 2025
One-click install
npx skills add https://github.com/codethread/claude-code-plugins --skill lang-typescript
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lang-typescript
Source: https://github.com/codethread/claude-code-plugins/tree/main/plugins/langs/skills/lang-typescript
Command: npx skills add https://github.com/codethread/claude-code-plugins --skill lang-typescript

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you write clean, robust TypeScript by selecting appropriate type primitives and patterns for common problems.

Core Features & Use Cases

  • Type decision tree: object shapes vs unions, branding, and more
  • Guidance on when to use interfaces vs types, branded types, and discriminated unions
  • Examples of best practices and pitfalls
  • Quick Start: a short snippet showing the recommended approach

Quick Start

Create a small example showing object shapes using interfaces and unions, and compile it with tsc.

Frequently Asked Questions about lang-typescript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write type-safe TypeScript code that catches errors at compile time?

Type-safe TypeScript uses strict mode and appropriate type primitives—interfaces, unions, and branded types—to validate data shapes and prevent runtime errors. This Skill guides you through type decision trees and best practices to select the right pattern for each problem, from object validation to discriminated unions.

When should I use interfaces versus types in TypeScript?

Interfaces and types serve different purposes: interfaces define object contracts and support declaration merging, while types offer greater flexibility for unions, intersections, and primitives. This Skill explains when each is appropriate and shows examples of common pitfalls to avoid.

How do I validate external data against TypeScript types at runtime?

Runtime validation ensures external data conforms to your type definitions before your code uses it. This Skill covers patterns like branded types and discriminated unions that bridge compile-time types and runtime checks, with guidance on configuring tsconfig for strict validation.

What are discriminated unions and when should I use them?

Discriminated unions use a shared literal field to narrow types safely and exhaustively. They prevent invalid state combinations and improve type inference. This Skill demonstrates their structure and contrasts them with other union patterns for handling multiple data shapes.

What does branded types mean and how do they improve type safety?

Branded types attach compile-time metadata to primitives without runtime overhead, creating nominal distinction between semantically different values. This Skill shows how to apply branding to prevent accidental misuse of IDs, emails, or currency values across your codebase.