Skip to content

Add types for String.{matchAll,replaceAll} with a well known symbol #61449

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

segevfiner
Copy link

Fixes #61448

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Mar 19, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 19, 2025
@segevfiner segevfiner force-pushed the regexp-symbol-replace-all-match-all branch from 72fb2ed to 36d187d Compare April 2, 2025 14:54
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Apr 2, 2025
* returns an iterable of matches containing the results of that search.
* @param regexp An object that supports being matched against.
*/
matchAll(matcher: { [Symbol.matchAll](str: string): RegExpStringIterator<RegExpMatchArray>; }): RegExpStringIterator<RegExpExecArray>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.prototype.matchAll, when on the [Symbol.matchAll] codepath, just forwards the call to the passed matcher and returns whatever it returns. There's no limitations on the type of the return and no coercion done. Should this then be generic in the return type?

matchAll<T>(matcher: { [Symbol.matchAll](str: string): T; }): T;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Add types for String.{matchAll,replaceAll} with a well known symbol
4 participants