-
Notifications
You must be signed in to change notification settings - Fork 12.8k
RegExpMatchArray
should extend [string, ...(string | undefined)[]]
#49228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
RegExpMatchArray
should extend (string | undefined)[]
RegExpMatchArray
should extend [string, ...(string | undefined)[]]
@MartinJohns May I know your point of objection? I understand you usually downvote issues that don't follow the template, but that's not the point here. So I guess it's about making string matching harder to work with? |
Because it would be a forced breaking change for a IMO rather uncommon case. This is also intentional, see: #17053 (comment) (although the comment is quite old.) |
Ah, I see. That issue didn't come up in my search. I guess it's still relevant today—going to close it as duplicate, then. |
lib Update Request
Configuration Check
My compilation target is
esnext
and my lib isthe default
.Missing / Incorrect Definition
RegExpMatchArray
extendsstring[]
, which can lead to unsound behavior.I understand this can make string matching a little unwieldy, but it has already been unwieldy since regexps aren't generic (ref #32098, #42296), so I suggest we at least ensure correctness.
Sample Code
Playground
This fails at runtime, because when we have an alternation of capturing groups, all capturing groups will have their corresponding slot in the match array, but some values could be
undefined
.Documentation Link
The text was updated successfully, but these errors were encountered: