type-level-error-messages

Installation
SKILL.md

Type-Level Error Messages

Related Skills: See typescript for general TypeScript conventions. See arktype for runtime regex validation and where this pattern surfaces in arktype itself.

When to Apply This Skill

Use this pattern when you need to:

  • Constrain object keys, string literals, or other literal-type inputs in a helper function and surface a readable error at the call site.
  • Replace a never or string return in a constraint type with something that points at the bad value.
  • Match the way arktype's internal ErrorMessage<M> types behave: visible message, invisible brand.
  • Give app authors edit-site feedback on shape/format rules (snake_case keys, slug formats, semver strings) without forcing every consumer to call a separate validate() step.

The pattern in one example

// 1. Predicate on the literal type.
type IsSnakeCase<S extends string> = /* recursive template literal walk */;
Installs
3
GitHub Stars
4.6K
First Seen
14 days ago
type-level-error-messages — epicenterhq/epicenter