typescript

Configure strict TypeScript projects with generics, utility types, and discriminated unions.

53|1|Updated Dec 18, 2025
One-click install
npx skills add https://github.com/cosmix/claude-code-setup --skill typescript-cosmix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/cosmix/claude-code-setup/tree/main/skills/typescript
Command: npx skills add https://github.com/cosmix/claude-code-setup --skill typescript-cosmix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill covers advanced TypeScript concepts, strict mode configuration, and robust type systems for maintainable code.

Core Features & Use Cases

  • Generics & Utility Types: Deep type safety and expressive APIs.
  • Discriminated Unions: Exhaustive handling of variants.
  • Module & Build: TS configuration with strict settings.

Quick Start

Define a generic repository interface and a type-safe factory function.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I set up strict mode TypeScript for production code?

Strict mode TypeScript enforces rigorous type checking by enabling compiler flags like `noImplicitAny`, `strictNullChecks`, and `strictFunctionTypes` in your `tsconfig.json`. This catches type errors at compile time, preventing runtime failures and ensuring type-safe APIs across frontend, backend, and library projects.

What are generics and utility types in TypeScript?

Generics enable you to write reusable, type-safe functions and classes that work with multiple types while maintaining full type information. Utility types like `Partial`, `Pick`, and `Record` transform existing types to create expressive, composable APIs without sacrificing type safety or runtime performance.

How do I use discriminated unions to handle type variants safely?

Discriminated unions use a literal type field to distinguish between variant shapes, enabling TypeScript to narrow types exhaustively. This pattern prevents runtime errors by forcing you to handle every variant case explicitly before accessing variant-specific properties.

Can I use TypeScript strict mode across different project types?

Yes, strict mode configuration applies uniformly across frontend applications, backend services, and library projects. The same strict compiler settings and type system features enforce consistency and catch errors regardless of the deployment target or module system you choose.

Why should I use type-safe factory functions instead of direct constructors?

Type-safe factory functions validate inputs and enforce type constraints at creation time, preventing invalid object states before they enter your application. This pattern is especially valuable in scalable software where composition and reusability matter across large codebases.

What module system configuration works best for TypeScript projects?

TypeScript supports ES modules, CommonJS, and other module systems through `tsconfig.json` settings. Choosing the right module system depends on your target environment and build tool, and strict mode works consistently across all module configurations.