In your readme example
const groups2 = typedRegExp('^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$', 'g').exec('2000-10-24')!.groups;
the complicated and error-prone escaping can be made simpler by using String.raw (or the equivalent TemplateStringsArray#raw
const groups2 = typedRegExp(String.raw`^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$`, 'g').exec('2000-10-24')!.groups;
allowing you to keep the same syntax as in the native regex, making it easy to transform from one form to the other.
You could adapt an api like typedRegExp`^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$`.g.exec("2000-10-24")!.groups to make it seamless. I haven't thought enough about it to decide if that's a good idea or not.
In your readme example
the complicated and error-prone escaping can be made simpler by using
String.raw(or the equivalentTemplateStringsArray#rawallowing you to keep the same syntax as in the native regex, making it easy to transform from one form to the other.
You could adapt an api like
typedRegExp`^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$`.g.exec("2000-10-24")!.groupsto make it seamless. I haven't thought enough about it to decide if that's a good idea or not.