How to use Object.values with TypeScript?

Sometimes, we want to use Object.values with TypeScript.

In this article, we’ll look at how to use Object.values with TypeScript.

How to use Object.values with TypeScript?

To use Object.values with TypeScript, we should set the compilerOptions.lib option to include 'es2017' or a later version of JavaScript.

For instance, we write

{
  //...
  "compilerOptions": {
    "lib": ["es2017", "dom"]
  }
  //...
}

in tsconfig.json to include 'es2017' in the compilerOptions.lib array so that the TypeScript compiler is aware that features in ES2017, including Object.values are available.

Conclusion

To use Object.values with TypeScript, we should set the compilerOptions.lib option to include 'es2017' or a later version of JavaScript.