Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
oakoss avatar

Typescript Patterns

  • 109 installs
  • 14 repo stars
  • Updated March 2, 2026
  • oakoss/agent-skills

Helps with ai & agent building tasks during AI-assisted development.

About

typescript-patterns is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.

  • typescript-patterns
  • AI & Agent Building
  • AI-coding skill

Typescript Patterns by the numbers

  • 109 all-time installs (skills.sh)
  • +9 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #4,092 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oakoss/agent-skills --skill typescript-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs109
repo stars14
Last updatedMarch 2, 2026
Repositoryoakoss/agent-skills

What it does

Helps with ai & agent building tasks during AI-assisted development.

Files

SKILL.mdMarkdownGitHub ↗

TypeScript Patterns

Overview

Advanced TypeScript patterns that use the type system to prevent runtime errors. Focuses on strict mode TypeScript with patterns for type inference, narrowing, and compile-time validation. Not a beginner tutorial.

When to use: Building type-safe APIs, complex data transformations, library authoring, preventing runtime errors through types, working with strict mode flags.

When NOT to use: Learning TypeScript basics (primitives, interfaces, classes), JavaScript-to-TypeScript migration guidance, tooling setup, or build configuration.

Quick Reference

PatternAPIKey Points
Utility typesPick<T, K>, Omit<T, K>Extract or exclude properties
Partial/RequiredPartial<T>, Required<T>Make properties optional or required
Record typeRecord<K, V>Object with known keys
Awaited typeAwaited<T>Unwrap Promise return types
ReturnType/ParametersReturnType<F>, Parameters<F>Extract function types
Generic constraints<T extends Type>Constrain generic parameters
Type inferencetype Inferred = typeof valueLet TypeScript infer from values
Type guardstypeof, instanceof, inNarrow types at runtime
Custom type guards(x): x is TypeUser-defined narrowing functions
Inferred predicates(x) => x !== nullAuto-inferred type predicate filters
Discriminated unionsUnion with literal type propertyExhaustive pattern matching
Conditional typesT extends U ? X : YType-level conditionals
Mapped types{ [K in keyof T]: T[K] }Transform all properties
Template literals` ${A}-${B} `String literal type manipulation
Const assertionsas constNarrowest possible literal types
Satisfies operatorvalue satisfies TypeType check without widening
NoInfer utilityNoInfer<T>Prevent inference from a position
Const type params<const T extends Type>Narrow inference without as const
Inline type importsimport { type User }Import types explicitly
Module augmentationdeclare module 'lib' { ... }Extend third-party types
Assertion functionsfunction assert(x): asserts x is TThrow if type guard fails

Common Mistakes

MistakeCorrect Pattern
Using any without justificationUse unknown and narrow with type guards
Manual type assertions everywhereLet inference work, type function returns
Destructuring before type narrowingKeep object intact for discriminated unions
Index access without undefined checkEnable noUncheckedIndexedAccess
as Type casting unsafe valuesUse satisfies Type to preserve narrow types
Inline objects in genericsExtract to const or type alias
Omitting extends in constraintsAlways constrain generics when possible
Using Parameters<typeof fn>[0]Type the parameter directly in function
Not handling union exhaustivenessUse never checks in switch/if-else
value as const satisfies TypeUse satisfies Type then as const if needed

Delegation

  • Pattern discovery: Use Explore agent to find existing patterns in codebase
  • Type error debugging: Use Task agent for multi-step type resolution
  • Code review: Delegate to code-reviewer skill for type safety audit

References

  • Type utilities (Pick, Omit, Partial, Required, Record, Extract, Exclude, ReturnType, Parameters, Awaited)
  • Generics (constraints, inference, default parameters, variance)
  • Type guards and narrowing (typeof, instanceof, in, custom guards, assertion functions)
  • Discriminated unions (exhaustive checking, never type, tagged unions)
  • Conditional types (distributive conditionals, infer keyword, type-level logic)
  • Mapped types (key remapping, template literals, modifiers)
  • Strict mode patterns (noUncheckedIndexedAccess, exactOptionalPropertyTypes, const assertions, satisfies)
  • Module patterns (inline type imports, declaration files, module augmentation, ambient types)
  • Modern idioms (eslint-plugin-unicorn patterns, modern array/string/DOM APIs, ES modules)

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.