From b6f5326faedc965c80f9f8b8415e62cb73422a94 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Tue, 22 Aug 2017 22:41:54 +0300 Subject: [PATCH] #305: add some time definitions --- flow-typed/npm/react-redux_v5.x.x.js | 114 +++++++++++++++++++++ flow-typed/npm/react-router_v4.x.x.js | 139 ++++++++++++++++++++++++++ flow-typed/npm/redux_v3.x.x.js | 109 ++++++++++++++++++++ 3 files changed, 362 insertions(+) create mode 100644 flow-typed/npm/react-redux_v5.x.x.js create mode 100644 flow-typed/npm/react-router_v4.x.x.js create mode 100644 flow-typed/npm/redux_v3.x.x.js diff --git a/flow-typed/npm/react-redux_v5.x.x.js b/flow-typed/npm/react-redux_v5.x.x.js new file mode 100644 index 0000000..7f7cb78 --- /dev/null +++ b/flow-typed/npm/react-redux_v5.x.x.js @@ -0,0 +1,114 @@ +// flow-typed signature: c5fac64666f9589a0c1b2de956dc7919 +// flow-typed version: 81d6274128/react-redux_v5.x.x/flow_>=v0.53.x + +// flow-typed signature: 8db7b853f57c51094bf0ab8b2650fd9c +// flow-typed version: ab8db5f14d/react-redux_v5.x.x/flow_>=v0.30.x + +import type { Dispatch, Store } from "redux"; + +declare module "react-redux" { + /* + + S = State + A = Action + OP = OwnProps + SP = StateProps + DP = DispatchProps + + */ + + declare type MapStateToProps = ( + state: S, + ownProps: OP + ) => SP | MapStateToProps; + + declare type MapDispatchToProps = + | ((dispatch: Dispatch, ownProps: OP) => DP) + | DP; + + declare type MergeProps = ( + stateProps: SP, + dispatchProps: DP, + ownProps: OP + ) => P; + + declare type Context = { store: Store<*, *> }; + + declare class ConnectedComponent extends React$Component { + static WrappedComponent: Class>, + getWrappedInstance(): React$Component

, + props: OP, + state: void + } + + declare type ConnectedComponentClass = Class< + ConnectedComponent + >; + + declare type Connector = ( + component: React$ComponentType

+ ) => ConnectedComponentClass; + + declare class Provider extends React$Component<{ + store: Store, + children?: any + }> {} + + declare function createProvider( + storeKey?: string, + subKey?: string + ): Provider<*, *>; + + declare type ConnectOptions = { + pure?: boolean, + withRef?: boolean + }; + + declare type Null = null | void; + + declare function connect( + ...rest: Array // <= workaround for https://github.com/facebook/flow/issues/2360 + ): Connector } & OP>>; + + declare function connect( + mapStateToProps: Null, + mapDispatchToProps: Null, + mergeProps: Null, + options: ConnectOptions + ): Connector } & OP>>; + + declare function connect( + mapStateToProps: MapStateToProps, + mapDispatchToProps: Null, + mergeProps: Null, + options?: ConnectOptions + ): Connector } & OP>>; + + declare function connect( + mapStateToProps: Null, + mapDispatchToProps: MapDispatchToProps, + mergeProps: Null, + options?: ConnectOptions + ): Connector>; + + declare function connect( + mapStateToProps: MapStateToProps, + mapDispatchToProps: MapDispatchToProps, + mergeProps: Null, + options?: ConnectOptions + ): Connector>; + + declare function connect( + mapStateToProps: MapStateToProps, + mapDispatchToProps: Null, + mergeProps: MergeProps, + options?: ConnectOptions + ): Connector; + + declare function connect( + mapStateToProps: MapStateToProps, + mapDispatchToProps: MapDispatchToProps, + mergeProps: MergeProps, + options?: ConnectOptions + ): Connector; +} diff --git a/flow-typed/npm/react-router_v4.x.x.js b/flow-typed/npm/react-router_v4.x.x.js new file mode 100644 index 0000000..c456f47 --- /dev/null +++ b/flow-typed/npm/react-router_v4.x.x.js @@ -0,0 +1,139 @@ +// flow-typed signature: b45080e7e6a55f1c9092f07c205cd527 +// flow-typed version: 3e35e41eb5/react-router_v4.x.x/flow_v0.53.x + +// flow-typed signature: b701192ca557cf27adf1b295517299fd +// flow-typed version: b43dff3e0e/react-router_v4.x.x/flow_>=v0.53.x +import * as React from "react"; + +declare module "react-router" { + // NOTE: many of these are re-exported by react-router-dom and + // react-router-native, so when making changes, please be sure to update those + // as well. + declare export type Location = { + pathname: string, + search: string, + hash: string, + state?: any, + key?: string + }; + + declare export type LocationShape = { + pathname?: string, + search?: string, + hash?: string, + state?: any + }; + + declare export type HistoryAction = "PUSH" | "REPLACE" | "POP"; + + declare export type RouterHistory = { + length: number, + location: Location, + action: HistoryAction, + listen( + callback: (location: Location, action: HistoryAction) => void + ): () => void, + push(path: string | LocationShape, state?: any): void, + replace(path: string | LocationShape, state?: any): void, + go(n: number): void, + goBack(): void, + goForward(): void, + canGo?: (n: number) => boolean, + block( + callback: (location: Location, action: HistoryAction) => boolean + ): void, + // createMemoryHistory + index?: number, + entries?: Array + }; + + declare export type Match = { + params: { [key: string]: ?string }, + isExact: boolean, + path: string, + url: string + }; + + declare export type ContextRouter = { + history: RouterHistory, + location: Location, + match: Match + }; + + declare export type GetUserConfirmation = ( + message: string, + callback: (confirmed: boolean) => void + ) => void; + + declare type StaticRouterContext = { + url?: string + }; + + declare type StaticRouterProps = { + basename?: string, + location?: string | Location, + context: StaticRouterContext, + children?: React$Element<*> + }; + declare export class StaticRouter extends React$Component< + StaticRouterProps + > {} + + declare type MemoryRouterProps = { + initialEntries?: Array, + initialIndex?: number, + getUserConfirmation?: GetUserConfirmation, + keyLength?: number, + children?: React$Element<*> + }; + declare export class MemoryRouter extends React$Component< + MemoryRouterProps + > {} + + declare type RouterProps = { + history: RouterHistory, + children?: React$Element<*> + }; + declare export class Router extends React$Component {} + + declare type PromptProps = { + message: string | ((location: Location) => string | true), + when?: boolean + }; + declare export class Prompt extends React$Component {} + + declare type RedirectProps = { + to: string | LocationShape, + push?: boolean + }; + declare export class Redirect extends React$Component {} + + declare type RouteProps = { + component?: React$ComponentType<*>, + render?: (router: ContextRouter) => React$Element<*>, + children?: (router: ContextRouter) => React$Element<*>, + path?: string, + exact?: boolean, + strict?: boolean + }; + declare export class Route extends React$Component {} + + declare type SwithcProps = { + children?: Array> + }; + declare export class Switch extends React$Component {} + + declare export function withRouter

( + Component: React$ComponentType + ): React$ComponentType

; + + declare type MatchPathOptions = { + exact?: boolean, + strict?: boolean + }; + declare export function matchPath( + pathname: string, + path: string, + options?: MatchPathOptions + ): null | Match; +} diff --git a/flow-typed/npm/redux_v3.x.x.js b/flow-typed/npm/redux_v3.x.x.js new file mode 100644 index 0000000..f6445d9 --- /dev/null +++ b/flow-typed/npm/redux_v3.x.x.js @@ -0,0 +1,109 @@ +// flow-typed signature: 86993bd000012d3e1ef10d757d16952d +// flow-typed version: a165222d28/redux_v3.x.x/flow_>=v0.33.x + +declare module 'redux' { + + /* + + S = State + A = Action + D = Dispatch + + */ + + declare type DispatchAPI = (action: A) => A; + declare type Dispatch }> = DispatchAPI; + + declare type MiddlewareAPI> = { + dispatch: D; + getState(): S; + }; + + declare type Store> = { + // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages) + dispatch: D; + getState(): S; + subscribe(listener: () => void): () => void; + replaceReducer(nextReducer: Reducer): void + }; + + declare type Reducer = (state: S, action: A) => S; + + declare type CombinedReducer = (state: $Shape & {} | void, action: A) => S; + + declare type Middleware> = + (api: MiddlewareAPI) => + (next: D) => D; + + declare type StoreCreator> = { + (reducer: Reducer, enhancer?: StoreEnhancer): Store; + (reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + }; + + declare type StoreEnhancer> = (next: StoreCreator) => StoreCreator; + + declare function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; + declare function createStore(reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + + declare function applyMiddleware(...middlewares: Array>): StoreEnhancer; + + declare type ActionCreator = (...args: Array) => A; + declare type ActionCreators = { [key: K]: ActionCreator }; + + declare function bindActionCreators, D: DispatchAPI>(actionCreator: C, dispatch: D): C; + declare function bindActionCreators, D: DispatchAPI>(actionCreators: C, dispatch: D): C; + + declare function combineReducers(reducers: O): CombinedReducer<$ObjMap(r: Reducer) => S>, A>; + + declare function compose(ab: (a: A) => B): (a: A) => B + declare function compose( + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => C + declare function compose( + cd: (c: C) => D, + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => D + declare function compose( + de: (d: D) => E, + cd: (c: C) => D, + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => E + declare function compose( + ef: (e: E) => F, + de: (d: D) => E, + cd: (c: C) => D, + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => F + declare function compose( + fg: (f: F) => G, + ef: (e: E) => F, + de: (d: D) => E, + cd: (c: C) => D, + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => G + declare function compose( + gh: (g: G) => H, + fg: (f: F) => G, + ef: (e: E) => F, + de: (d: D) => E, + cd: (c: C) => D, + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => H + declare function compose( + hi: (h: H) => I, + gh: (g: G) => H, + fg: (f: F) => G, + ef: (e: E) => F, + de: (d: D) => E, + cd: (c: C) => D, + bc: (b: B) => C, + ab: (a: A) => B + ): (a: A) => I + +}