Skip to content

Commit

Permalink
Merge pull request #12547 from Microsoft/Revert12207
Browse files Browse the repository at this point in the history
Revert #12207
  • Loading branch information
mhegazy authored Nov 29, 2016
2 parents c89b1eb + 82e84e2 commit e313fef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
13 changes: 12 additions & 1 deletion src/lib/es2017.object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ interface ObjectConstructor {
* @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[];

/**
* 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(o: any): any[];

/**
* 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][];

/**
* 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 extends { [key: string]: any }, K extends keyof T>(o: T): [keyof T, T[K]][];
entries(o: any): [string, any][];
}
30 changes: 15 additions & 15 deletions tests/baselines/reference/useObjectValuesAndEntries1.types
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,38 @@ for (var x of Object.values(o)) {
}

var entries = Object.entries(o); // <-- entries: ['a' | 'b', number][]
>entries : ["a" | "b", number][]
>Object.entries(o) : ["a" | "b", number][]
>Object.entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries : [string, number][]
>Object.entries(o) : [string, number][]
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>Object : ObjectConstructor
>entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries : { <T>(o: { [s: string]: 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 extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>Object : ObjectConstructor
>entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>1 : 1

var entries2 = Object.entries({a: true, b: 2}) // ['a' | 'b', number | boolean][]
>entries2 : ["a" | "b", number | boolean][]
>Object.entries({a: true, b: 2}) : ["a" | "b", number | boolean][]
>Object.entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>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 : ObjectConstructor
>entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>{a: true, b: 2} : { a: true; b: number; }
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>{a: true, b: 2} : { a: true; b: 2; }
>a : boolean
>true : true
>b : number
>2 : 2

var entries3 = Object.entries({}) // [never, any][]
>entries3 : [never, any][]
>Object.entries({}) : [never, any][]
>Object.entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries3 : [string, {}][]
>Object.entries({}) : [string, {}][]
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>Object : ObjectConstructor
>entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>{} : {}

8 changes: 4 additions & 4 deletions tests/baselines/reference/useObjectValuesAndEntries4.types
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ for (var x of Object.values(o)) {
}

var entries = Object.entries(o);
>entries : ["a" | "b", number][]
>Object.entries(o) : ["a" | "b", number][]
>Object.entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries : [string, number][]
>Object.entries(o) : [string, number][]
>Object.entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>Object : ObjectConstructor
>entries : { <T extends { [key: string]: any; }, K extends keyof T>(o: T): [keyof T, T[K]][]; (o: any): [string, any][]; }
>entries : { <T>(o: { [s: string]: T; }): [string, T][]; (o: any): [string, any][]; }
>o : { a: number; b: number; }

0 comments on commit e313fef

Please sign in to comment.