You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What do you want to use this for? Better type inference when using RegExps
What shortcomings exist with current approaches? All keys of groups are string which can lead to errors if accessing a property that isn't in the RegExp
What workarounds are you using in the meantime? Casting to the expected type
The text was updated successfully, but these errors were encountered:
π Search Terms
regex capture group types inference
β Viability Checklist
β Suggestion
I think it would be useful to have capture groups inside of regexps to be represented in the type of
RegExpExecArray.groups
π Motivating Example
Given the following RegExp:
The type of
groups
should be inferred as:This may imply that the type of
RegExp
needs to be generic over the named capture groups, so something like this:π» Use Cases
groups
arestring
which can lead to errors if accessing a property that isn't in the RegExpThe text was updated successfully, but these errors were encountered: