-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
RegExpIndicesArray type definition incomplete #61078
Comments
FWIW this "works" as you expect if you use |
Like #49228 and issues linked from there? Not considered worth the breakage in those other issues, from the looks of it |
Yes, the spec guarantees the behaviour of getting
|
π Search Terms
RegExpIndicesArray, Regex indices
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?target=99#code/DYUwLgBAlgdgJlAxiAzhAvBAFAeiwLwEoAfLAQxKwCNLFCc5CA6EADxESwCIyrEvCAfiawEyFAG4AUFABm2UUlQQAhOkwBXeCFmwQjCAG8pEUxFCQyGaPCUoA2gEYAuhIg4cEezA0BbKiAATgA0ED7+Qc4QZIiIAPaBCDAA5hBgcRAAKgCeAA6oiIFQuWAmZnLkGOoQWnA6egbGZs0Q8TAocaBMwHHJ3Dn5KIXFkChk2WhgABZQaIhkMDBxkFNkufkwAtLNAL4QIMAoIEZlLa1x7Z0g3b3khNtmO1JPQA
π» Code
π Actual behavior
The elements of the RegExpIndicesArray can be undefined, if a capturing group did not match anything at all.
This is demonstrated by running the code above, and by the spec
https://tc39.es/ecma262/multipage/text-processing.html#sec-regexpbuiltinexec
(34. b. ii. Append undefined to indices.)
π Expected behavior
I expected the Typescript type definitions to tell me that the elements of the indices array can be undefined.
Additional information about the issue
Am creating a PR with a fix
The text was updated successfully, but these errors were encountered: