Categories
TypeScript Answers

How to fix the “Property ‘matchAll’ does not exist on type ‘string'” error with TypeScript?

Spread the love

Sometimes, we want to fix the "Property ‘matchAll’ does not exist on type ‘string’" error with TypeScript.

In this article, we’ll look at how to fix the "Property ‘matchAll’ does not exist on type ‘string’" error with TypeScript.

How to fix the "Property ‘matchAll’ does not exist on type ‘string’" error with TypeScript?

To fix the "Property ‘matchAll’ does not exist on type ‘string’" error with TypeScript, we can add the "es2020.string" entry into compilerOptions.lib in tsconfig.json.

For instance, we write

{
  //...
  "compilerOptions": {
    "lib": ["es2020.string"]
  }
  //...
}

to add the "es2020.string" entry into compilerOptions.lib in tsconfig.json.

Then the TypeScript compiler knows that the string matchAll method is available for use in our TypeScript project.

Conclusion

To fix the "Property ‘matchAll’ does not exist on type ‘string’" error with TypeScript, we can add the "es2020.string" entry into compilerOptions.lib in tsconfig.json.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.