Skip to content

Commit bc43904

Browse files
committed
[fix] ES5 Object.keys only accepts an object
1 parent 4ff71ec commit bc43904

8 files changed

+18
-12
lines changed

src/lib/es2015.core.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ interface ObjectConstructor {
298298
*/
299299
getOwnPropertySymbols(o: any): symbol[];
300300

301+
/**
302+
* Returns the names of the enumerable string properties and methods of an object.
303+
* @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.
304+
*/
305+
keys(o: {}): string[];
306+
301307
/**
302308
* Returns true if the values are the same value, false otherwise.
303309
* @param value1 The first value.

src/lib/es5.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ interface ObjectConstructor {
235235
isExtensible(o: any): boolean;
236236

237237
/**
238-
* Returns the names of the enumerable properties and methods of an object.
238+
* Returns the names of the enumerable string properties and methods of an object.
239239
* @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.
240240
*/
241241
keys(o: {}): string[];

tests/baselines/reference/contextualExpressionTypecheckingDoesntBlowStack.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default class Operation {
2121

2222
for(const parameterLocation of Object.keys(parameterValues)) {
2323
>parameterLocation : Symbol(parameterLocation, Decl(contextualExpressionTypecheckingDoesntBlowStack.ts, 8, 17))
24-
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
24+
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
2525
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
26-
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
26+
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
2727
>parameterValues : Symbol(parameterValues, Decl(contextualExpressionTypecheckingDoesntBlowStack.ts, 6, 23))
2828

2929
const parameter: any = (this as any).getParameter();;

tests/baselines/reference/contextualExpressionTypecheckingDoesntBlowStack.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default class Operation {
2121
for(const parameterLocation of Object.keys(parameterValues)) {
2222
>parameterLocation : string
2323
>Object.keys(parameterValues) : string[]
24-
>Object.keys : (o: {}) => string[]
24+
>Object.keys : { (o: object): string[]; (o: {}): string[]; }
2525
>Object : ObjectConstructor
26-
>keys : (o: {}) => string[]
26+
>keys : { (o: object): string[]; (o: {}): string[]; }
2727
>parameterValues : any
2828

2929
const parameter: any = (this as any).getParameter();;

tests/baselines/reference/genericIndexedAccessMethodIntersectionCanBeAccessed.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export const createService = <T>(
3232
>Object.keys(ServiceCtr).forEach(key => { const method = (ServiceCtr)[key as keyof T]; const {__$daemonMode, __$action, id} = method; }) : void
3333
>Object.keys(ServiceCtr).forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
3434
>Object.keys(ServiceCtr) : string[]
35-
>Object.keys : (o: {}) => string[]
35+
>Object.keys : (o: object) => string[]
3636
>Object : ObjectConstructor
37-
>keys : (o: {}) => string[]
37+
>keys : (o: object) => string[]
3838
>ServiceCtr : ExtendedService<T> & Service<T>
3939
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
4040
>key => { const method = (ServiceCtr)[key as keyof T]; const {__$daemonMode, __$action, id} = method; } : (key: string) => void

tests/baselines/reference/literalTypeWidening.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ export function keys<K extends string, V>(obj: Record<K, V>): K[] {
391391
return Object.keys(obj) as K[]
392392
>Object.keys(obj) as K[] : K[]
393393
>Object.keys(obj) : string[]
394-
>Object.keys : (o: {}) => string[]
394+
>Object.keys : (o: object) => string[]
395395
>Object : ObjectConstructor
396-
>keys : (o: {}) => string[]
396+
>keys : (o: object) => string[]
397397
>obj : Record<K, V>
398398
}
399399

tests/baselines/reference/recursiveTypeRelations.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export function css<S extends { [K in keyof S]: string }>(styles: S, ...classNam
7272
>Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; }, {}) : any
7373
>Object.keys(arg).reduce : { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; <U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }
7474
>Object.keys(arg) : string[]
75-
>Object.keys : (o: {}) => string[]
75+
>Object.keys : (o: object) => string[]
7676
>Object : ObjectConstructor
77-
>keys : (o: {}) => string[]
77+
>keys : (o: object) => string[]
7878
>arg : ClassNameObjectMap<S>
7979
>reduce : { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; <U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }
8080
>(obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; } : (obj: any, key: keyof S) => any

tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
8989
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
9090
~~~~~~~
9191
!!! error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'?
92-
!!! related TS2728 /.ts/lib.es2015.core.d.ts:466:5: 'fixed' is declared here.
92+
!!! related TS2728 /.ts/lib.es2015.core.d.ts:472:5: 'fixed' is declared here.
9393
fn5 `${ (n) => n.substr(0) }`;
9494

9595

0 commit comments

Comments
 (0)