agentsclimarketplace

Typescript patterns

Skill Tibsfox/gsd-skill-creator/project-claude/skills/typescript-patterns

TypeScript best practices and patterns. Use when writing TypeScript, fixing type errors, or working with generics.From its SKILL.md

Install
npx -y skills add Tibsfox/gsd-skill-creator --skill typescript-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

1.4 KB, 304 tokens by cl100k_base, as published. Nobody here has run it

TypeScript Patterns

Type vs Interface

Use CasePrefer
Object shapeinterface
Union typestype
Extending shapesinterface
Intersectiontype
Tuple/primitivestype

Key Patterns

Discriminated Unions — model state with tagged types:

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

Type Guards — narrow at runtime:

function isUser(obj: unknown): obj is User {
  return typeof obj === 'object' && obj !== null && 'id' in obj;
}

Generic Constraints:

function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] { return obj[key]; }

Utility Types

TypePurpose
Partial<T>All optional
Required<T>All required
Pick<T,K>Select properties
Omit<T,K>Remove properties
Record<K,V>Key-value map
ReturnType<T>Function return type

Avoid

  • any — use unknown and narrow
  • Type assertions (as) — use type guards
  • ! operator — handle null properly
  • Missing return types on complex functions

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.