下面的 ts 代码编译时报错 Property 'matchAll' does not exist
const regex = /!\[(\[.+?\])\][\s\S]+?\1:\s*(.*?)\s+/g
const matches = text.matchAll(regex)
请问如何解决这个问题?
是 tsconfig.json 中 "target": "ES2015"
引起的,改为 "target": "ES2020"
即可解决
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
}
}