Property 'values' does not exist on type 'ObjectConstructor'

You are calling Object.values(...) while targeting es2015 (also known as ES6). Unfortunately this feature first appears in es2017 (also known as ES8), as you can see in the specifications for ES6, ES7, ES8 (first appearance of Object.values) or the MDN article.

The compiler adjusts itself to the target and reports to you that it doesn't know the function (in that version).

You may use a polyfill (as mentioned in the MDN article) or change TypeScript's target to es2017 or esnext. If you want to let it run in a browser environment, you might have to transpile that to a lower ECMAScript version like your original target es2015. This can be accomplished with Babel. There are many resources on the web which show you the details (and even more lately, as Babel 7 has been released with better support for TypeScript).

By the way, this question is very similar to this ones:

  • Property 'assign' does not exist on type 'ObjectConstructor'
  • Property 'entries' does not exist on type ObjectConstructor

add es2017.object to the compilerOptions.lib array in your tsconfig.json.


You have "target": "es2015", but Object.values is not a part of es2015. Its a part of es2017 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values

Fix

Use "target": "ESNext" which has that feature.

Tags:

Typescript