typescript-advanced-patterns

v2026.09.24

Advanced TypeScript — type-level programming, library/DSL APIs, declaration merging, modern language features at depth (decorators, using, const T, NoInfer, variance), and feature implementation patterns built on advanced types. Trigger on tasks involving recursive conditional types, infer patterns, mapped-type key remapping, variadic tuples, fluent builders with phantom state, schema-first inference (Zod/Valibot), end-to-end-typed API clients, finite state machines, module augmentation, and library-publishing concerns. Trigger even when the user does not say "advanced" — if the work involves type-level algorithms, library-author API design, or going beyond surface-level uses of TS 5.x features, this is the skill. Assumes the reader has absorbed the `typescript-refactor` skill — this one extends those patterns at depth, never restates them.

GitHub
安装命令
npx skhub add pproenca/typescript-advanced-patterns
Markdown
SKILL.md

TypeScript Advanced Patterns Best Practices

Type-level programming, library-author idioms, and feature-implementation patterns that go beyond surface uses of TypeScript 5.x. Contains 40 rules across 5 categories, prioritised by impact on consumer codebases.

When to Apply

Reference these guidelines when:

  • Designing a public library or DSL surface (fluent builders, event emitters, route parsers, query builders, schema-derived clients)
  • Writing type-level algorithms (recursive conditionals, accumulator pattern, key remapping, variadic tuples, type-level string/number ops, type-level tests)
  • Using TS 5.x features in non-trivial ways (Stage 3 decorators, using composition, const T for overload disambiguation, NoInfer for anchor-vs-constrained parameters, variance annotations, the bivariance hole)
  • Encoding workflow state, transitions, and capabilities at the type level so illegal states and missing checks are compile errors
  • Integrating with the declaration & module system (module augmentation, declaration merging, ambient asset modules, library type publishing via exports/typesVersions)

Boundary with neighbouring skills

SkillDon't reach for this skill if you need…
typescript (curated)Compiler performance / tsconfig tuning
typescript-refactorGeneral refactoring patterns and modern-TS surface basics
ts-googleGoogle-style code style decisions
clean-code-ts-reactClean-code principles (naming, function shape, abstraction)
effect-ts / opencode-tsEffect library-specific patterns

If a rule in this skill overlaps with one in typescript-refactor or .curated/typescript, the rule's Scope delta section names what this skill adds beyond the simpler version.

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1Library Author / DSL PatternsCRITICALdsl-8
2Type-level ProgrammingHIGHtlp-10
3Modern Features at DepthHIGHmod-8
4Feature Implementation PatternsMEDIUM-HIGHimpl-8
5Declaration & Module SystemMEDIUMdecl-6

Quick Reference

1. Library Author / DSL Patterns (CRITICAL)

2. Type-level Programming (HIGH)

3. Modern Features at Depth (HIGH)

4. Feature Implementation Patterns (MEDIUM-HIGH)

5. Declaration & Module System (MEDIUM)

How to Use

Read individual reference files for detailed explanations, code examples, and "when NOT to apply" guidance:

Rules cross-link via [[other-rule-slug]]; follow them when a related pattern is referenced.

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information
发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

Sep 24, 2026

分类

未分类

许可证

MIT

源路径

skills/.experimental/typescript-advanced-patterns

默认分支

master

最新提交

cf93c57

Tree SHA

afbb575