Add types for String.{matchAll,replaceAll} with a well known symbol#61449
Add types for String.{matchAll,replaceAll} with a well known symbol#61449segevfiner wants to merge 2 commits intomicrosoft:mainfrom
String.{matchAll,replaceAll} with a well known symbol#61449Conversation
72fb2ed to
36d187d
Compare
| * 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>; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
Wouldn't this apply to all the other [Symbol] RegExp symbols. I don't think it was done for them, it would also make it inconvenient to call, as in the common case, its supposed to return RegExpStringIterator<RegExpMatchArray>, returning something else is technically unexpected, and kinda violates what the symbol is meant to do.
|
With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies). Next steps for PRs:
|
Fixes #61448