typescript

Enforce compile-time type safety in TypeScript code.

3|Updated Aug 17, 2020
One-click install
npx skills add https://github.com/d-kimuson/dotfiles --skill typescript-d-kimuson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/d-kimuson/dotfiles/tree/main/claude-code/skills/typescript
Command: npx skills add https://github.com/d-kimuson/dotfiles --skill typescript-d-kimuson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill promotes TypeScript best practices, emphasizing type safety, avoiding unsafe assertions, and leveraging modern patterns to move validation from runtime to compile time.

Core Features & Use Cases

  • Type safety discipline: Rules against as-assertions and any, with recommended alternatives.
  • Strict typing patterns: Use const + satisfies, exhaustive discriminated unions, and explicit typing strategies.
  • External data handling: Promote validated parsing and safe API client usage.

Quick Start

Refactor a function using a generic any type to a strongly-typed alternative with a proper interface.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I prevent runtime type errors in TypeScript code?

Prevent runtime type errors by enforcing compile-time type safety through strict typing, discriminated unions, and exhaustive pattern matching. Avoid unsafe assertions like 'as' and validate external data with proper parsing before use.

What's the difference between 'as' type assertions and 'as const satisfies' in TypeScript?

'as const satisfies' provides safer, more precise type narrowing than 'as' assertions. It preserves literal types while enforcing compile-time validation, reducing the risk of accidental type mismatches.

How do I safely handle external API data in TypeScript?

Safely handle external data by rejecting any-typed responses and applying runtime validation through strongly-typed interfaces and parsing functions. Move validation logic from runtime to compile time using strict typing patterns.

When should I use discriminated unions in TypeScript?

Use discriminated unions to enforce exhaustive pattern matching and eliminate ambiguous type states. They enable compile-time verification that all cases are handled, preventing runtime errors from unhandled types.

Can I enforce type safety rules across a TypeScript codebase?

Yes, enforce type safety discipline by banning unsafe patterns like 'as' assertions and 'any' types across your codebase. Use strict typing, literal types, and validated data structures to maintain compile-time correctness.