From 5f1b09f95ceed16650ada8a4df3807fe534753b1 Mon Sep 17 00:00:00 2001 From: Wyatt Cready Date: Thu, 3 Aug 2017 12:24:43 -0400 Subject: [PATCH 1/3] Provide more helpful tuples for Object.entries() and Object.values() --- lib/core.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/core.js b/lib/core.js index 22f74a51b56..3ee585a8d14 100644 --- a/lib/core.js +++ b/lib/core.js @@ -35,7 +35,9 @@ declare class Object { static create(o: any, properties?: any): any; // compiler magic static defineProperties(o: any, properties: any): any; static defineProperty(o: any, p: any, attributes: any): any; - static entries(object: any): Array<[string, mixed]>; + static entries (o: { [s: string]: T }) : Array<[string, T]>; + static entries (o: Array | $ReadOnlyArray) : Array<[string, T]>; + static entries (o: any) : Array<[string, mixed]>; static freeze(o: T): T; static getOwnPropertyDescriptor(o: any, p: any): any; static getOwnPropertyNames(o: any): Array; @@ -49,7 +51,9 @@ declare class Object { static preventExtensions(o: any): any; static seal(o: any): any; static setPrototypeOf(o: any, proto: ?Object): bool; - static values(object: any): Array; + static values (o: { [s: string]: T }) : Array; + static values (o: Array | $ReadOnlyArray) : Array; + static values(o: any): Array; hasOwnProperty(prop: any): boolean; isPrototypeOf(o: any): boolean; propertyIsEnumerable(prop: any): boolean; From 52882eb68895228e43fadc6b151286f9db14acb7 Mon Sep 17 00:00:00 2001 From: Wyatt Cready Date: Sat, 5 Aug 2017 12:39:53 -0400 Subject: [PATCH 2/3] Accept objects with covariant properties Normal objects should still flow into this --- lib/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core.js b/lib/core.js index 3ee585a8d14..9ed29cc1cee 100644 --- a/lib/core.js +++ b/lib/core.js @@ -35,7 +35,7 @@ declare class Object { static create(o: any, properties?: any): any; // compiler magic static defineProperties(o: any, properties: any): any; static defineProperty(o: any, p: any, attributes: any): any; - static entries (o: { [s: string]: T }) : Array<[string, T]>; + static entries (o: { +[s: string]: T }) : Array<[string, T]>; static entries (o: Array | $ReadOnlyArray) : Array<[string, T]>; static entries (o: any) : Array<[string, mixed]>; static freeze(o: T): T; @@ -51,7 +51,7 @@ declare class Object { static preventExtensions(o: any): any; static seal(o: any): any; static setPrototypeOf(o: any, proto: ?Object): bool; - static values (o: { [s: string]: T }) : Array; + static values (o: { +[s: string]: T }) : Array; static values (o: Array | $ReadOnlyArray) : Array; static values(o: any): Array; hasOwnProperty(prop: any): boolean; From f4593d2035b0aac72998ab1bb5554a01db58433b Mon Sep 17 00:00:00 2001 From: Wyatt Cready Date: Mon, 7 Aug 2017 13:47:46 -0400 Subject: [PATCH 3/3] Add better definition for Object.keys() Resolves https://github.com/facebook/flow/issues/4553 --- lib/core.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/core.js b/lib/core.js index 9ed29cc1cee..3dad5d2454d 100644 --- a/lib/core.js +++ b/lib/core.js @@ -47,6 +47,7 @@ declare class Object { static isExtensible(o: any): boolean; static isFrozen(o: any): boolean; static isSealed(o: any): boolean; + static keys (o: { +[key: T]: any }): Array; static keys(o: any): Array; static preventExtensions(o: any): any; static seal(o: any): any;