From a867c00ec860144c8484007b3e2405faf954ddbb Mon Sep 17 00:00:00 2001 From: quanganhtran <9863988+quanganhtran@users.noreply.github.com> Date: Sat, 14 Apr 2018 09:17:42 +0300 Subject: [PATCH 1/3] Fix Flow typing for observable.map --- flow-typed/mobx.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flow-typed/mobx.js b/flow-typed/mobx.js index 15b3269b4..c1cc79fbd 100644 --- a/flow-typed/mobx.js +++ b/flow-typed/mobx.js @@ -236,7 +236,10 @@ export interface IObservableFactory { declare export class IObservableFactories { box(value?: T, name?: string): IObservableValue, array(initialValues?: T[], name?: string): IObservableArray, - map(initialValues?: IObservableMapInitialValues, name?: string): ObservableMap, + map( + initialValues?: IObservableMapInitialValues, + name?: string + ): ObservableMap, object(props: T, name?: string): T & IObservableObject, ref(target: Object, property?: string, descriptor?: PropertyDescriptor): any, shallow(target: Object, property?: string, descriptor?: PropertyDescriptor): any, From 6f0bb9beb5ba7bd32aa2011e59181a02f83011f1 Mon Sep 17 00:00:00 2001 From: quanganhtran <9863988+quanganhtran@users.noreply.github.com> Date: Sat, 14 Apr 2018 11:27:16 +0300 Subject: [PATCH 2/3] Update MobX 4 observable factories --- flow-typed/mobx.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/flow-typed/mobx.js b/flow-typed/mobx.js index c1cc79fbd..b5e658d22 100644 --- a/flow-typed/mobx.js +++ b/flow-typed/mobx.js @@ -1,5 +1,11 @@ // @flow +export type CreateObservableOptions = { + name?: string, + deep?: boolean, + defaultDecorator?: any +} + export type IObservableMapInitialValues = IMapEntries | KeyValueMap | IMap export interface IMobxConfigurationOptions { @@ -234,13 +240,13 @@ export interface IObservableFactory { } declare export class IObservableFactories { - box(value?: T, name?: string): IObservableValue, - array(initialValues?: T[], name?: string): IObservableArray, + box(value?: T, options?: CreateObservableOptions): IObservableValue, + array(initialValues?: T[], options?: CreateObservableOptions): IObservableArray, map( initialValues?: IObservableMapInitialValues, - name?: string + options?: CreateObservableOptions ): ObservableMap, - object(props: T, name?: string): T & IObservableObject, + object(props: T, options?: CreateObservableOptions): T & IObservableObject, ref(target: Object, property?: string, descriptor?: PropertyDescriptor): any, shallow(target: Object, property?: string, descriptor?: PropertyDescriptor): any, deep(target: Object, property?: string, descriptor?: PropertyDescriptor): any From dbef2ab94dee1d3f90374d6d010fdbc88a9e8745 Mon Sep 17 00:00:00 2001 From: quanganhtran <9863988+quanganhtran@users.noreply.github.com> Date: Sun, 15 Apr 2018 19:56:21 +0300 Subject: [PATCH 3/3] Add IObservableDecorator to Flow type --- flow-typed/mobx.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/flow-typed/mobx.js b/flow-typed/mobx.js index b5e658d22..67cd3ee3a 100644 --- a/flow-typed/mobx.js +++ b/flow-typed/mobx.js @@ -1,11 +1,5 @@ // @flow -export type CreateObservableOptions = { - name?: string, - deep?: boolean, - defaultDecorator?: any -} - export type IObservableMapInitialValues = IMapEntries | KeyValueMap | IMap export interface IMobxConfigurationOptions { @@ -239,6 +233,17 @@ export interface IObservableFactory { (value: T): T } +export type IObservableDecorator = { + (target: Object, property: string, descriptor?: PropertyDescriptor): void, + enhancer: IEnhancer +} + +export type CreateObservableOptions = { + name?: string, + deep?: boolean, + defaultDecorator?: IObservableDecorator +} + declare export class IObservableFactories { box(value?: T, options?: CreateObservableOptions): IObservableValue, array(initialValues?: T[], options?: CreateObservableOptions): IObservableArray, @@ -247,9 +252,13 @@ declare export class IObservableFactories { options?: CreateObservableOptions ): ObservableMap, object(props: T, options?: CreateObservableOptions): T & IObservableObject, - ref(target: Object, property?: string, descriptor?: PropertyDescriptor): any, - shallow(target: Object, property?: string, descriptor?: PropertyDescriptor): any, - deep(target: Object, property?: string, descriptor?: PropertyDescriptor): any + ref(target: Object, property?: string, descriptor?: PropertyDescriptor): IObservableDecorator, + shallow( + target: Object, + property?: string, + descriptor?: PropertyDescriptor + ): IObservableDecorator, + deep(target: Object, property?: string, descriptor?: PropertyDescriptor): IObservableDecorator } export interface Iterator {