Skip to content

Commit 9c141f4

Browse files
author
Ryan Johnson
authored
Feature/add flowtype (#20)
* add flowtype support to project
1 parent 9b96893 commit 9c141f4

File tree

17 files changed

+2390
-182
lines changed

17 files changed

+2390
-182
lines changed

.babelrc

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
{
2-
"presets": [
3-
["es2015", { "loose": true, "modules": "commonjs" }],
4-
"react",
5-
"stage-0"
6-
],
2+
"presets": ["es2015-no-commonjs", "react", "stage-0"],
3+
"plugins": ["transform-flow-strip-types"],
74
"env": {
8-
"cjs": {
9-
"presets": [
10-
["es2015", { "loose": true, "modules": "commonjs" }],
11-
"react",
12-
"stage-0"
13-
],
14-
"plugins": ["add-module-exports"]
5+
"development": {
6+
"plugins": ["transform-es2015-modules-commonjs"]
157
},
16-
"es": {
17-
"presets": [
18-
["es2015", { "loose": true, "modules": false }],
19-
"react",
20-
"stage-0"
21-
]
8+
"commonjs": {
9+
"plugins": ["transform-es2015-modules-commonjs"]
10+
},
11+
"test": {
12+
"plugins": ["transform-es2015-modules-commonjs"]
2213
}
2314
}
2415
}

.flowconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[lints]
8+
9+
[options]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ lib
1616
es
1717
dist
1818
site
19+
.vscode

flow-typed/npm/flat_vx.x.x.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// flow-typed signature: 16f0c69e5bc835af23ef2764e7f8b9f8
2+
// flow-typed version: <<STUB>>/flat_v^2.0.1/flow_v0.53.1
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'flat'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'flat' {
17+
declare export function flatten(Object, options: ?any): Object;
18+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// flow-typed signature: 114add35a1264a6ed8b59d446306b830
2+
// flow-typed version: aff2bf770e/react-redux_v4.x.x/flow_>=v0.53.x
3+
4+
import type { Dispatch, Store } from "redux";
5+
6+
declare module "react-redux" {
7+
/*
8+
9+
S = State
10+
A = Action
11+
OP = OwnProps
12+
SP = StateProps
13+
DP = DispatchProps
14+
15+
*/
16+
17+
declare type MapStateToProps<S, OP: Object, SP: Object> = (
18+
state: S,
19+
ownProps: OP
20+
) => SP;
21+
22+
declare type MapDispatchToProps<A, OP: Object, DP: Object> =
23+
| ((dispatch: Dispatch<A>, ownProps: OP) => DP)
24+
| DP;
25+
26+
declare type MergeProps<SP, DP: Object, OP: Object, P: Object> = (
27+
stateProps: SP,
28+
dispatchProps: DP,
29+
ownProps: OP
30+
) => P;
31+
32+
declare class ConnectedComponent<OP, P> extends React$Component<OP> {
33+
static WrappedComponent: Class<React$Component<P>>,
34+
getWrappedInstance(): React$Component<P>,
35+
props: OP,
36+
state: void
37+
}
38+
39+
declare type ConnectedComponentClass<OP, P> = Class<
40+
ConnectedComponent<OP, P>
41+
>;
42+
43+
declare type Connector<OP, P> = (
44+
component: React$ComponentType<P>
45+
) => ConnectedComponentClass<OP, P>;
46+
47+
declare class Provider<S, A> extends React$Component<{
48+
store: Store<S, A>,
49+
children?: any
50+
}> {}
51+
52+
declare type ConnectOptions = {
53+
pure?: boolean,
54+
withRef?: boolean
55+
};
56+
57+
declare type Null = null | void;
58+
59+
declare function connect<A, OP>(
60+
...rest: Array<void> // <= workaround for https://github.com/facebook/flow/issues/2360
61+
): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
62+
63+
declare function connect<A, OP>(
64+
mapStateToProps: Null,
65+
mapDispatchToProps: Null,
66+
mergeProps: Null,
67+
options: ConnectOptions
68+
): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
69+
70+
declare function connect<S, A, OP, SP>(
71+
mapStateToProps: MapStateToProps<S, OP, SP>,
72+
mapDispatchToProps: Null,
73+
mergeProps: Null,
74+
options?: ConnectOptions
75+
): Connector<OP, $Supertype<SP & { dispatch: Dispatch<A> } & OP>>;
76+
77+
declare function connect<A, OP, DP>(
78+
mapStateToProps: Null,
79+
mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
80+
mergeProps: Null,
81+
options?: ConnectOptions
82+
): Connector<OP, $Supertype<DP & OP>>;
83+
84+
declare function connect<S, A, OP, SP, DP>(
85+
mapStateToProps: MapStateToProps<S, OP, SP>,
86+
mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
87+
mergeProps: Null,
88+
options?: ConnectOptions
89+
): Connector<OP, $Supertype<SP & DP & OP>>;
90+
91+
declare function connect<S, A, OP, SP, DP, P>(
92+
mapStateToProps: MapStateToProps<S, OP, SP>,
93+
mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
94+
mergeProps: MergeProps<SP, DP, OP, P>,
95+
options?: ConnectOptions
96+
): Connector<OP, P>;
97+
}

flow-typed/npm/redux_v3.x.x.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// flow-typed signature: 86993bd000012d3e1ef10d757d16952d
2+
// flow-typed version: a165222d28/redux_v3.x.x/flow_>=v0.33.x
3+
4+
declare module 'redux' {
5+
6+
/*
7+
8+
S = State
9+
A = Action
10+
D = Dispatch
11+
12+
*/
13+
14+
declare type DispatchAPI<A> = (action: A) => A;
15+
declare type Dispatch<A: { type: $Subtype<string> }> = DispatchAPI<A>;
16+
17+
declare type MiddlewareAPI<S, A, D = Dispatch<A>> = {
18+
dispatch: D;
19+
getState(): S;
20+
};
21+
22+
declare type Store<S, A, D = Dispatch<A>> = {
23+
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
24+
dispatch: D;
25+
getState(): S;
26+
subscribe(listener: () => void): () => void;
27+
replaceReducer(nextReducer: Reducer<S, A>): void
28+
};
29+
30+
declare type Reducer<S, A> = (state: S, action: A) => S;
31+
32+
declare type CombinedReducer<S, A> = (state: $Shape<S> & {} | void, action: A) => S;
33+
34+
declare type Middleware<S, A, D = Dispatch<A>> =
35+
(api: MiddlewareAPI<S, A, D>) =>
36+
(next: D) => D;
37+
38+
declare type StoreCreator<S, A, D = Dispatch<A>> = {
39+
(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
40+
(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
41+
};
42+
43+
declare type StoreEnhancer<S, A, D = Dispatch<A>> = (next: StoreCreator<S, A, D>) => StoreCreator<S, A, D>;
44+
45+
declare function createStore<S, A, D>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
46+
declare function createStore<S, A, D>(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>;
47+
48+
declare function applyMiddleware<S, A, D>(...middlewares: Array<Middleware<S, A, D>>): StoreEnhancer<S, A, D>;
49+
50+
declare type ActionCreator<A, B> = (...args: Array<B>) => A;
51+
declare type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> };
52+
53+
declare function bindActionCreators<A, C: ActionCreator<A, any>, D: DispatchAPI<A>>(actionCreator: C, dispatch: D): C;
54+
declare function bindActionCreators<A, K, C: ActionCreators<K, A>, D: DispatchAPI<A>>(actionCreators: C, dispatch: D): C;
55+
56+
declare function combineReducers<O: Object, A>(reducers: O): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
57+
58+
declare function compose<A, B>(ab: (a: A) => B): (a: A) => B
59+
declare function compose<A, B, C>(
60+
bc: (b: B) => C,
61+
ab: (a: A) => B
62+
): (a: A) => C
63+
declare function compose<A, B, C, D>(
64+
cd: (c: C) => D,
65+
bc: (b: B) => C,
66+
ab: (a: A) => B
67+
): (a: A) => D
68+
declare function compose<A, B, C, D, E>(
69+
de: (d: D) => E,
70+
cd: (c: C) => D,
71+
bc: (b: B) => C,
72+
ab: (a: A) => B
73+
): (a: A) => E
74+
declare function compose<A, B, C, D, E, F>(
75+
ef: (e: E) => F,
76+
de: (d: D) => E,
77+
cd: (c: C) => D,
78+
bc: (b: B) => C,
79+
ab: (a: A) => B
80+
): (a: A) => F
81+
declare function compose<A, B, C, D, E, F, G>(
82+
fg: (f: F) => G,
83+
ef: (e: E) => F,
84+
de: (d: D) => E,
85+
cd: (c: C) => D,
86+
bc: (b: B) => C,
87+
ab: (a: A) => B
88+
): (a: A) => G
89+
declare function compose<A, B, C, D, E, F, G, H>(
90+
gh: (g: G) => H,
91+
fg: (f: F) => G,
92+
ef: (e: E) => F,
93+
de: (d: D) => E,
94+
cd: (c: C) => D,
95+
bc: (b: B) => C,
96+
ab: (a: A) => B
97+
): (a: A) => H
98+
declare function compose<A, B, C, D, E, F, G, H, I>(
99+
hi: (h: H) => I,
100+
gh: (g: G) => H,
101+
fg: (f: F) => G,
102+
ef: (e: E) => F,
103+
de: (d: D) => E,
104+
cd: (c: C) => D,
105+
bc: (b: B) => C,
106+
ab: (a: A) => B
107+
): (a: A) => I
108+
109+
}

0 commit comments

Comments
 (0)