Global Rank · of 601 Skills
typescript-patterns AI Agent Skill
View Source: oakoss/agent-skills
SafeInstallation
npx skills add oakoss/agent-skills --skill typescript-patterns 46
Installs
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
| Pattern | API | Key Points |
|---|---|---|
| Utility types | Pick<T, K>, Omit<T, K> |
Extract or exclude properties |
| Partial/Required | Partial<T>, Required<T> |
Make properties optional or required |
| Record type | Record<K, V> |
Object with known keys |
| Awaited type | Awaited<T> |
Unwrap Promise return types |
| ReturnType/Parameters | ReturnType<F>, Parameters<F> |
Extract function types |
| Generic constraints | <T extends Type> |
Constrain generic parameters |
| Type inference | type Inferred = typeof value |
Let TypeScript infer from values |
| Type guards | typeof, instanceof, in |
Narrow types at runtime |
| Custom type guards | (x): x is Type |
User-defined narrowing functions |
| Inferred predicates | (x) => x !== null |
Auto-inferred type predicate filters |
| Discriminated unions | Union with literal type property |
Exhaustive pattern matching |
| Conditional types | T extends U ? X : Y |
Type-level conditionals |
| Mapped types | { [K in keyof T]: T[K] } |
Transform all properties |
| Template literals | `${A}-${B}` |
String literal type manipulation |
| Const assertions | as const |
Narrowest possible literal types |
| Satisfies operator | value satisfies Type |
Type check without widening |
| NoInfer utility | NoInfer<T> |
Prevent inference from a position |
| Const type params | <const T extends Type> |
Narrow inference without as const |
| Inline type imports | import { type User } |
Import types explicitly |
| Module augmentation | declare module 'lib' { ... } |
Extend third-party types |
| Assertion functions | function assert(x): asserts x is T |
Throw if type guard fails |
Common Mistakes
| Mistake | Correct Pattern |
|---|---|
Using any without justification |
Use unknown and narrow with type guards |
| Manual type assertions everywhere | Let inference work, type function returns |
| Destructuring before type narrowing | Keep object intact for discriminated unions |
| Index access without undefined check | Enable noUncheckedIndexedAccess |
as Type casting unsafe values |
Use satisfies Type to preserve narrow types |
| Inline objects in generics | Extract to const or type alias |
Omitting extends in constraints |
Always constrain generics when possible |
Using Parameters<typeof fn>[0] |
Type the parameter directly in function |
| Not handling union exhaustiveness | Use never checks in switch/if-else |
value as const satisfies Type |
Use satisfies Type then as const if needed |
Delegation
- Pattern discovery: Use
Exploreagent to find existing patterns in codebase - Type error debugging: Use
Taskagent for multi-step type resolution - Code review: Delegate to
code-reviewerskill 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)
Installs
Security Audit
View Source
oakoss/agent-skills
More from this source
Power your AI Agents with
the best open-source models.
Drop-in OpenAI-compatible API. No data leaves Europe.
Explore Inference APIGLM
GLM 5
$1.00 / $3.20
per M tokens
Kimi
Kimi K2.5
$0.60 / $2.80
per M tokens
MiniMax
MiniMax M2.5
$0.30 / $1.20
per M tokens
Qwen
Qwen3.5 122B
$0.40 / $3.00
per M tokens
How to use this skill
Install typescript-patterns by running npx skills add oakoss/agent-skills --skill typescript-patterns in your project directory. Run the install command above in your project directory. The skill file will be downloaded from GitHub and placed in your project.
No configuration needed. Your AI agent (Claude Code, Cursor, Windsurf, etc.) automatically detects installed skills and uses them as context when generating code.
The skill enhances your agent's understanding of typescript-patterns, helping it follow established patterns, avoid common mistakes, and produce production-ready output.
What you get
Skills are plain-text instruction files — not executable code. They encode expert knowledge about frameworks, languages, or tools that your AI agent reads to improve its output. This means zero runtime overhead, no dependency conflicts, and full transparency: you can read and review every instruction before installing.
Compatibility
This skill works with any AI coding agent that supports the skills.sh format, including Claude Code (Anthropic), Cursor, Windsurf, Cline, Aider, and other tools that read project-level context files. Skills are framework-agnostic at the transport level — the content inside determines which language or framework it applies to.
Chat with 100+ AI Models in one App.
Use Claude, ChatGPT, Gemini alongside with EU-Hosted Models like Deepseek, GLM-5, Kimi K2.5 and many more.