TypeScript

Refactor JavaScript code into pragmatic, well-typed TypeScript functions.

8|1|Updated Feb 16, 2026
One-click install
npx skills add https://github.com/caidanw/skills --skill typescript-caidanw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TypeScript
Source: https://github.com/caidanw/skills/tree/main/typescript
Command: npx skills add https://github.com/caidanw/skills --skill typescript-caidanw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers write cleaner, more maintainable, and robust TypeScript code by providing best practices and patterns for pragmatic functional programming.

Core Features & Use Cases

  • Clarity and Readability: Emphasizes simple, explicit code over dense, complex logic.
  • Composable Functions: Encourages small, reusable functions that are easy to combine.
  • Type Safety: Leverages TypeScript's features like discriminated unions to make illegal states unrepresentable.
  • Use Case: Refactor a complex JavaScript function into clear, well-typed TypeScript functions that are easier to understand and debug.

Quick Start

Use the TypeScript skill to refactor the provided JavaScript code into a more pragmatic and maintainable TypeScript structure.

Frequently Asked Questions about TypeScript

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

FAQPage Schema
What is the best way to write maintainable TypeScript code?

To make illegal states unrepresentable in TypeScript, use discriminated unions and branded types to enforce sound typing. This technique leverages the compiler to prevent invalid state combinations at build time rather than runtime.

How do I refactor JavaScript into well-typed TypeScript functions?

To refactor JavaScript into well-typed TypeScript functions, break complex logic down into small, reusable, and composable functions. Apply sound typing and discriminated unions to ensure clarity, readability, and robust type safety throughout the codebase.

Does functional programming work well with TypeScript type safety?

Functional programming works exceptionally well with TypeScript type safety by combining higher-order functions and sound typing. This synergy allows developers to build composable, reusable functions while guaranteeing robust code quality and maintainability.

Why should I use discriminated unions in TypeScript?

You should use discriminated unions in TypeScript to make illegal states unrepresentable and enforce sound typing. This pattern ensures only valid state combinations are compilable, significantly reducing runtime errors and improving code quality.