Typescript: Add definition for Object.entries and Object.values in lib.es2017.d.ts

Created on 5 May 2016  路  7Comments  路  Source: microsoft/TypeScript

The proposal is at stage 4 now. here is the spec: https://github.com/tc39/proposal-object-values-entries

here is the definition skeleton:

interface ObjectConstructor {
    keys(o: any): string[];
    values<T>(o: { [s: string]: T }): T[];
    values(o: any): any[];
    entries<T>(o: { [s: string]: T }): [string, T][];
    entries(o: any): [string, any][];
}
Bug lib.d.ts ES Next Fixed

Most helpful comment

Are you using "lib": [ "es2017.object" ]?

All 7 comments

Hi! Does this gets transpiled to ES5? Or this are just the definitions?

TypeScript does not polyfill functionality, it only down-emits syntactical constructs. If you want this functionality in ES5, you will need to use an external polyfill library like core-js.

I use core-js already, but the typescript compiler throws when trying to access to values in ObjectConstructor

Are you using "lib": [ "es2017.object" ]?

When I add "lib": [ "es2017.object" ] my code editor now doesn't recognize Object or any other js global?

I was a little bit unclear, in that once you use "lib", you have to specify all the library files you need. So you would want to have something like "lib": [ "dom", "es2017" ] in which es2017 will load all the built-ins of ES2017, ES2016, ES5 and ES3 as well as the DOM related libraries. When you specify a _sub_ library, it will only load that one.

@kitsonk That worked! Thanks Much 馃憤

Was this page helpful?
0 / 5 - 0 ratings