From a8dcdadf9d32fc040120cbd86a733104a882e850 Mon Sep 17 00:00:00 2001 From: A-gambit Date: Mon, 28 Nov 2016 17:52:14 +0200 Subject: [PATCH] update flow types --- .flowconfig | 2 +- flow-typed/mobx.js | 51 ++++++++++++++++++++++------------------------ package.json | 2 +- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.flowconfig b/.flowconfig index 08cec1b6c..41afc31ab 100644 --- a/.flowconfig +++ b/.flowconfig @@ -8,4 +8,4 @@ test/flow flow-typed/ [options] -suppress_comment= \\(.\\|\n\\)*\\$ExpectError \ No newline at end of file +suppress_comment= \\(.\\|\n\\)*\\$ExpectError diff --git a/flow-typed/mobx.js b/flow-typed/mobx.js index cd212fb32..83206f461 100644 --- a/flow-typed/mobx.js +++ b/flow-typed/mobx.js @@ -4,19 +4,20 @@ declare module 'mobx' { getAtom: (thing: any, property?: string) => IDepTreeNode, getDebugName: (thing: any, property?: string) => string, getDependencyTree: (thing: any, property?: string) => IDependencyTree, + getGlobalState: () => any; getObserverTree: (thing: any, property?: string) => IObserverTree, isComputingDerivation: () => boolean, isSpyEnabled: () => boolean, resetGlobalState: () => void, + shareGlobalState: () => void; spyReport: (event: any) => boolean, spyReportEnd: (change?: any) => void, spyReportStart: (event: any) => void, - trackTransitions: (onReport?: (c: any) => void) => Lambda, setReactionScheduler: (fn: (f: () => void) => void) => void }; declare interface IInterceptable { - interceptors: IInterceptor[], + interceptors: IInterceptor[] | any, intercept(handler: IInterceptor): Lambda } @@ -68,22 +69,6 @@ declare module 'mobx' { ): Lambda } - declare interface IDerivation { - observing: IObservable[], - newObserving: IObservable[], - dependenciesState: IDerivationState, - runId: number, - unboundDepsCount: number, - ___mapid: string, - onBecomeStale(): any, - recoverFromError(): any - } - - declare interface IDepTreeNode { - name: string, - observing?: IObservable[] - } - declare interface IObservable { diffValue: number, lastAccessedBy: number, @@ -96,12 +81,29 @@ declare module 'mobx' { onBecomeUnobserved(): any } + declare interface IDepTreeNode { + name: string, + observing?: IObservable[] + } + + declare interface IDerivation { + name: string, + observing: IObservable[], + newObserving: ?IObservable[], + dependenciesState: IDerivationState, + runId: number, + unboundDepsCount: number, + ___mapid: string, + onBecomeStale(): any, + recoverFromError(): any + } + declare interface IReactionPublic { dispose: () => void } declare interface IListenable { - changeListeners: Function[], + changeListeners: any, observe( handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean ): Lambda @@ -118,7 +120,7 @@ declare module 'mobx' { replace(newItems: T[]): T[], find( predicate: (item: T, index: number, array: Array) => boolean, thisArg?: any, fromIndex?: number - ): T, + ): T | any, remove(value: T): boolean } @@ -250,9 +252,6 @@ declare module 'mobx' { declare function isAction(thing: any): boolean; declare function autorun(nameOrFunction: string | (r: IReactionPublic) => void, viewOrScope?: any, scope?: any): any; declare function when(predicate: () => boolean, effect: Lambda, scope?: any): any - declare function autorunUntil( - predicate: () => boolean, effect: (r: IReactionPublic) => void, scope?: any - ): any declare function autorunAsync(func: (r: IReactionPublic) => void, delay?: number, scope?: any): any declare function reaction( expression: () => T, effect: (arg: T, r: IReactionPublic) => void, fireImmediately?: boolean, delay?: number, scope?: any @@ -260,7 +259,7 @@ declare module 'mobx' { declare function computed(target: any, key?: string, baseDescriptor?: PropertyDescriptor): any declare function createTransformer( - transformer: ITransformer, onCleanup?: (resultObject: B, sourceObject?: A) => void + transformer: ITransformer, onCleanup?: (resultObject: ?B | any, sourceObject?: A) => void ): ITransformer declare function expr(expr: () => T, scope?: any): T declare function extendObservable(target: A, ...properties: B[]): A & B @@ -275,12 +274,11 @@ declare module 'mobx' { declare function observable(value: T): any declare function observe( - object: any, property: string, listener: (newValue: any, oldValue: any) => void, fireImmediately?: boolean + object: any, property: string, listener: (newValue: any, oldValue?: any) => void, fireImmediately?: boolean ): Lambda declare function toJS(source: any, detectCycles: boolean, ___alreadySeen: [any, any][]): any declare function toJSlegacy(source: any, detectCycles?: boolean, ___alreadySeen?: [any, any][]): any - declare function toJSON(source: any, detectCycles?: boolean, ___alreadySeen?: [any, any][]): any declare function whyRun(thing?: any, prop?: string): string declare function useStrict(strict: boolean): any @@ -295,7 +293,6 @@ declare module 'mobx' { declare function asStructure(value: T): T declare function asFlat(value: T): T declare function asMap(data: IKeyValueMap, modifierFunc?: Function): ObservableMap - declare function fastArray(initialValues?: V[]): IObservableArray declare function isObservableArray(thing: any): boolean declare function map( diff --git a/package.json b/package.json index 71e02377f..46ea5abc4 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test-browser-chrome": "npm run small-build && ( browserify test/*.js | tape-run --browser chrome | faucet )", "test-browser-safari": "npm run small-build && ( browserify test/*.js -t [ babelify --presets [ es2015 ] ] | tape-run --browser safari | faucet )", "test-browser-firefox": "npm run small-build && ( browserify test/*.js | tape-run --browser firefox | faucet )", - "test-travis": "npm run small-build && npm run build-tests && tape test/*.js test/perf/index.js && tsc && istanbul cover tape test/*.js && && npm run test-flow", + "test-travis": "npm run small-build && npm run build-tests && tape test/*.js test/perf/index.js && tsc && istanbul cover tape test/*.js && npm run test-flow", "test-flow": "node_modules/.bin/flow check", "coverage": "npm run quick-build && npm run build-tests && istanbul cover tape test/*.js", "build-tests": "npm run build-typescript-tests && npm run build-babel-tests",