Property 'matchAll' does not exist on type 'string'
String.prototype.matchAll() is part of the ECMAScript 2020 specification (draft).In TypeScript you can include these library features by adding es2020
or es2020.string
, in the compiler options:
"compilerOptions": { "lib": ["es2020.string"]}
Checking the ts signature for the String
and RegExp
classes I realized there is no signature for matchAll
. One manner to solve it could be:
let matches = str['matchAll'](regexp);