Typescript

From dean0x/devflow · View interactive version

Typescript is an AI agent skill from the GitHub repository dean0x/devflow. This skill should be used when the user works with TypeScript files (.ts/.tsx), asks about "generics", "type guards", "utility types", "discriminated unions", or discusses type safety.

How to use this skill

Skill file

TypeScript Patterns

Iron Law

UNKNOWN OVER ANY

Never use any. Use unknown with type guards instead. any disables TypeScript's

entire value proposition — if you need flexibility, use generics; if you need to handle

arbitrary data, use unknown and validate. any is giving up. [1, Item 43]

Type Safety

Generic Patterns

Discriminated Unions

Make illegal states unrepresentable: encode each variant in the type, for results and request states.

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

Branded Types

Structural typing treats UserId and OrderId (both string) as identical.

Brand IDs and amounts for nominal distinction with zero runtime cost.

declare const brand: unique symbol;
type Brand<T, B> = T & { [brand]: B };
type UserId = Brand<string, 'UserId'>; // getUser(orderId) is a compile error

Conditional & Mapped Types

Extended References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.