Install any skill in seconds. Free to start, no credit card required.
Get Started Free →aiskillstore/typescript-best-practices
Use when reading or writing TypeScript or JavaScript files (.ts, .tsx, .js, tsconfig.json).
Passed 21 of 22 test cases with the skill, and 16 of 22 without it.
and 2 more in the full report
5 fixed16 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 5 test cases the skill fixed. Same model, same prompt, with and without the skill.
In my IDE, hover tooltips for an intersected type `TypeA & TypeB & { id: string }` display the raw unexpanded intersection formula. What utility type flattens complex intersections into a single readable object type in IDE tooltips?
| Checked | Without skill | With skill |
|---|---|---|
| Uses `Simplify` from `type-fest`. | Missed | Passed |
The instructions your model reads when the skill loads.
Follows type-first, functional, and error handling patterns from CLAUDE.md. This skill covers language-specific idioms only.
When working with React components (.tsx, .jsx files or @react imports), always load react-best-practices alongside this skill. This skill covers TypeScript fundamentals; React-specific patterns (effects, hooks, refs, component design) are in the dedicated React skill.
Use the type system to prevent invalid states at compile time.
Discriminated unions for mutually exclusive states:
// Good: only valid combinations possible
type RequestState<T> =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'success'; data: T }
| { status: 'error'; error: Error };
// Bad: allows invalid combinations like { loading: true, error: Error }
type RequestState<T> = {
loading: boolean;
data?: T;
error?: Error;
};
Branded types for domain primitives:
type UserId = string & { readonly __brand: 'UserId' };
type OrderId = string & { readonly __brand: 'OrderId' };
// Compiler prevents passing OrderId where UserId expected
function getUser(id: UserId): Promise<User> { /* ... */ }
Const assertions for literal unions:
test cases passed, vs 16 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.