What problem does it solve?
TypeScript's default error output for invalid literal keys or string shapes is cryptic (e.g. "not assignable to type 'never'"), giving library authors no way to point consumers at the exact offending value. This Skill provides a pattern for making compile-time errors read as plain English sentences.
Core Features & Use Cases
- Branded template-literal error types: Encode the full error message in the type itself, so TS surfaces it at the exact bad property.
- Recursive template-literal predicates: Validate string shapes like snake_case, kebab-case, or semver at the type level where regex-based tools fall back to
string.
- Paired runtime validation: Combine the compile-time check with a regex guard inside the helper function to catch dynamic keys and
as casts.
- Use Case: When building a
defineActions helper that only accepts snake_case keys, a consumer writing tabs.close sees Type 'Action' is not assignable to type 'Invalid action key "tabs.close", must be snake_case ASCII...' instead of an opaque assignability failure.
Quick Start
Ask the AI to add a type-level snake_case constraint with a readable branded error message to a helper function like defineActions, following this Skill's pattern.