Skip to content

feat: add matchers for TemplateLiteral types #51

Description

@martyy-code

Description

Add first-class matchers for TypeScript TemplateLiteral types. TemplateLiteral types (e.g. literal string patterns like /users/${string}/posts/${number}) are used in route typing, DSLs, and string parsers. No existing type-testing library tests them.

Why

TemplateLiteral types are increasingly common (Next.js route types, tRPC, Zod schemas). Testing that a utility preserves or transforms template literals correctly is painful today. A dedicated matcher makes this trivial.

Acceptance criteria

  • Matcher that extracts the literal parts of a TemplateLiteral type
  • Matcher that validates a TemplateLiteral against a pattern
  • Tests: infer from template, extract placeholders, match against strings

Risks

  • Low. TemplateLiteral is well-specified in TS. The challenge is making error messages readable.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:typesType utilities (Equal, IsAny, IsNever, ...)enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions