Type-Level RegExp (current version 0.1.17) is a TypeScript library that implements a regular expression parser and matcher entirely at the type level, leveraging TypeScript's template literal types. It allows developers to define regex patterns as string literals and receive compile-time type-safe results when using `String.match()`, `String.matchAll()`, and `String.replace()`. This provides robust validation of regex syntax and strongly typed access to capture groups, significantly reducing runtime errors related to incorrect regex patterns or mismatched group access. The library is currently under active development ('Work In Progress'), implying an iterative release cadence focused on feature expansion and refinement. Its primary differentiator is the deep integration of regex parsing into the TypeScript type system, offering static analysis benefits not typically found in runtime-only regex solutions.
npm install type-level-regexpVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `createRegExp` to get strongly typed match results for `String.match()`, `String.replace()`, and `String.matchAll()` against literal strings, including access to capture groups and iterator spreading.
Monitor the GitHub repository for updates and review release notes carefully before upgrading. Pin exact versions for production use and consider using the TypeScript Playground link to test changes.
For dynamic string matching, validate runtime results if strict typing is critical, or consider using runtime assertions. If possible, refactor to use literal strings where type-level guarantees are most valuable.
Ensure all regular expression patterns passed to `createRegExp` are syntactically valid and correctly formed according to JavaScript RegExp syntax. Utilize online regex testers or the provided TypeScript Playground link for validation during development.
Correct the regular expression string to be syntactically valid (e.g., ensure all opening parentheses have a matching closing parenthesis).
No dependency data recorded yet.