Improve Object.{values,entries} static methods (#18875)
This commit is contained in:
parent
5faa739483
commit
661ecc241e
3 changed files with 16 additions and 16 deletions
4
src/lib/es2017.object.d.ts
vendored
4
src/lib/es2017.object.d.ts
vendored
|
@ -3,7 +3,7 @@ interface ObjectConstructor {
|
|||
* Returns an array of values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T }): T[];
|
||||
values<T>(o: { [s: string]: T } | { [n: number]: T }): T[];
|
||||
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
|
@ -15,7 +15,7 @@ interface ObjectConstructor {
|
|||
* Returns an array of key/values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T }): [string, T][];
|
||||
entries<T>(o: { [s: string]: T } | { [n: number]: T }): [string, T][];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties of an object
|
||||
|
|
|
@ -10,9 +10,9 @@ var o = { a: 1, b: 2 };
|
|||
for (var x of Object.values(o)) {
|
||||
>x : number
|
||||
>Object.values(o) : number[]
|
||||
>Object.values : { <T>(o: { [s: string]: T; }): T[]; (o: any): any[]; }
|
||||
>Object.values : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): T[]; (o: any): any[]; }
|
||||
>Object : ObjectConstructor
|
||||
>values : { <T>(o: { [s: string]: T; }): T[]; (o: any): any[]; }
|
||||
>values : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): T[]; (o: any): any[]; }
|
||||
>o : { a: number; b: number; }
|
||||
|
||||
let y = x;
|
||||
|
@ -23,25 +23,25 @@ for (var x of Object.values(o)) {
|
|||
var entries = Object.entries(o); // <-- entries: ['a' | 'b', number][]
|
||||
>entries : [string, number][]
|
||||
>Object.entries(o) : [string, number][]
|
||||
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object.entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object : ObjectConstructor
|
||||
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>o : { a: number; b: number; }
|
||||
|
||||
var entries1 = Object.entries(1); // <-- entries: [string, any][]
|
||||
>entries1 : [string, any][]
|
||||
>Object.entries(1) : [string, any][]
|
||||
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object.entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object : ObjectConstructor
|
||||
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>1 : 1
|
||||
|
||||
var entries2 = Object.entries({a: true, b: 2}) // ['a' | 'b', number | boolean][]
|
||||
>entries2 : [string, number | boolean][]
|
||||
>Object.entries({a: true, b: 2}) : [string, number | boolean][]
|
||||
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object.entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object : ObjectConstructor
|
||||
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>{a: true, b: 2} : { a: true; b: 2; }
|
||||
>a : boolean
|
||||
>true : true
|
||||
|
@ -51,8 +51,8 @@ var entries2 = Object.entries({a: true, b: 2}) // ['a' | 'b', number | boolean][
|
|||
var entries3 = Object.entries({}) // [never, any][]
|
||||
>entries3 : [string, {}][]
|
||||
>Object.entries({}) : [string, {}][]
|
||||
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object.entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object : ObjectConstructor
|
||||
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>{} : {}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ var o = { a: 1, b: 2 };
|
|||
for (var x of Object.values(o)) {
|
||||
>x : number
|
||||
>Object.values(o) : number[]
|
||||
>Object.values : { <T>(o: { [s: string]: T; }): T[]; (o: any): any[]; }
|
||||
>Object.values : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): T[]; (o: any): any[]; }
|
||||
>Object : ObjectConstructor
|
||||
>values : { <T>(o: { [s: string]: T; }): T[]; (o: any): any[]; }
|
||||
>values : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): T[]; (o: any): any[]; }
|
||||
>o : { a: number; b: number; }
|
||||
|
||||
let y = x;
|
||||
|
@ -23,8 +23,8 @@ for (var x of Object.values(o)) {
|
|||
var entries = Object.entries(o);
|
||||
>entries : [string, number][]
|
||||
>Object.entries(o) : [string, number][]
|
||||
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object.entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>Object : ObjectConstructor
|
||||
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>entries : { <T>(o: { [s: string]: T; } | { [n: number]: T; }): [string, T][]; (o: any): [string, any][]; }
|
||||
>o : { a: number; b: number; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue