The code-completion in IntelliJ only proposes RegExp.[Symbol.matchAll], but not RegExp.matchAll:

Typescript config settings:
"compilerOptions": {
"lib": ["es2020"],
"target": "es2020",
},
What can be the reason for this?
More info:
/x/[Symbol.matchAll]("axb")works at runtime (NodeJs 14).string.matchAll()works, butRegExp.matchAll()doesn't:

- Typescript version 4.3.5
CodePudding user response:
Because there is no Regex.prototype.matchAll method.
There is a String.prototype.matchAll method (which calls the method keyed to Symbol.matchAll under the hood), and there is a method on Regex.prototype[Symbol.matchAll] that behaves similarly, which is why your IDE is autocompleting it that way for you. Not sure why they decided to have the convenience method for Strings but not Regexes.
