瀏覽代碼

flow-typed

master
Lyubomir Marinov 8 年之前
父節點
當前提交
2063ad467d

+ 1
- 0
.eslintignore 查看文件

3
 
3
 
4
 # Third-party source code which we (1) do not want to modify or (2) try to
4
 # Third-party source code which we (1) do not want to modify or (2) try to
5
 # modify as little as possible.
5
 # modify as little as possible.
6
+flow-typed/*
6
 libs/*
7
 libs/*
7
 
8
 
8
 # ESLint will by default ignore its own configuration file. However, there does
9
 # ESLint will by default ignore its own configuration file. However, there does

+ 6
- 1
.jshintignore 查看文件

1
+# The following do not need to be checked because they do not represent JS
2
+# source code.
1
 build/
3
 build/
2
 debian/
4
 debian/
3
 libs/
5
 libs/
4
 node_modules/
6
 node_modules/
7
+
8
+# The following are checked by ESLint which supersedes JSHint.
9
+flow-typed/
5
 react/
10
 react/
11
+
6
 analytics.js
12
 analytics.js
7
-webpack.config.babel.js

+ 6
- 0
flow-typed/npm/flow-bin_v0.x.x.js 查看文件

1
+// flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583
2
+// flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x
3
+
4
+declare module "flow-bin" {
5
+  declare module.exports: string;
6
+}

+ 89
- 0
flow-typed/npm/react-redux_v5.x.x.js 查看文件

1
+// flow-typed signature: 0ed284c5a2e97a9e3c0e87af3dedc09d
2
+// flow-typed version: bdf1e66252/react-redux_v5.x.x/flow_>=v0.30.x
3
+
4
+import type { Dispatch, Store } from 'redux'
5
+
6
+declare module 'react-redux' {
7
+
8
+  /*
9
+
10
+    S = State
11
+    A = Action
12
+    OP = OwnProps
13
+    SP = StateProps
14
+    DP = DispatchProps
15
+
16
+  */
17
+
18
+  declare type MapStateToProps<S, OP: Object, SP: Object> = (state: S, ownProps: OP) => SP | MapStateToProps<S, OP, SP>;
19
+
20
+  declare type MapDispatchToProps<A, OP: Object, DP: Object> = ((dispatch: Dispatch<A>, ownProps: OP) => DP) | DP;
21
+
22
+  declare type MergeProps<SP, DP: Object, OP: Object, P: Object> = (stateProps: SP, dispatchProps: DP, ownProps: OP) => P;
23
+
24
+  declare type StatelessComponent<P> = (props: P) => ?React$Element<any>;
25
+
26
+  declare class ConnectedComponent<OP, P, Def, St> extends React$Component<void, OP, void> {
27
+    static WrappedComponent: Class<React$Component<Def, P, St>>;
28
+    getWrappedInstance(): React$Component<Def, P, St>;
29
+    static defaultProps: void;
30
+    props: OP;
31
+    state: void;
32
+  }
33
+
34
+  declare type ConnectedComponentClass<OP, P, Def, St> = Class<ConnectedComponent<OP, P, Def, St>>;
35
+
36
+  declare type Connector<OP, P> = {
37
+    (component: StatelessComponent<P>): ConnectedComponentClass<OP, P, void, void>;
38
+    <Def, St>(component: Class<React$Component<Def, P, St>>): ConnectedComponentClass<OP, P, Def, St>;
39
+  };
40
+
41
+  declare class Provider<S, A> extends React$Component<void, { store: Store<S, A>, children?: any }, void> { }
42
+
43
+  declare type ConnectOptions = {
44
+    pure?: boolean,
45
+    withRef?: boolean
46
+  };
47
+
48
+  declare type Null = null | void;
49
+
50
+  declare function connect<A, OP>(
51
+    ...rest: Array<void> // <= workaround for https://github.com/facebook/flow/issues/2360
52
+  ): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
53
+
54
+  declare function connect<A, OP>(
55
+    mapStateToProps: Null,
56
+    mapDispatchToProps: Null,
57
+    mergeProps: Null,
58
+    options: ConnectOptions
59
+  ): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;
60
+
61
+  declare function connect<S, A, OP, SP>(
62
+    mapStateToProps: MapStateToProps<S, OP, SP>,
63
+    mapDispatchToProps: Null,
64
+    mergeProps: Null,
65
+    options?: ConnectOptions
66
+  ): Connector<OP, $Supertype<SP & { dispatch: Dispatch<A> } & OP>>;
67
+
68
+  declare function connect<A, OP, DP>(
69
+    mapStateToProps: Null,
70
+    mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
71
+    mergeProps: Null,
72
+    options?: ConnectOptions
73
+  ): Connector<OP, $Supertype<DP & OP>>;
74
+
75
+  declare function connect<S, A, OP, SP, DP>(
76
+    mapStateToProps: MapStateToProps<S, OP, SP>,
77
+    mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
78
+    mergeProps: Null,
79
+    options?: ConnectOptions
80
+  ): Connector<OP, $Supertype<SP & DP & OP>>;
81
+
82
+  declare function connect<S, A, OP, SP, DP, P>(
83
+    mapStateToProps: MapStateToProps<S, OP, SP>,
84
+    mapDispatchToProps: MapDispatchToProps<A, OP, DP>,
85
+    mergeProps: MergeProps<SP, DP, OP, P>,
86
+    options?: ConnectOptions
87
+  ): Connector<OP, P>;
88
+
89
+}

+ 56
- 0
flow-typed/npm/redux_v3.x.x.js 查看文件

1
+// flow-typed signature: ba132c96664f1a05288f3eb2272a3c35
2
+// flow-typed version: c4bbd91cfc/redux_v3.x.x/flow_>=v0.33.x
3
+
4
+declare module 'redux' {
5
+
6
+  /*
7
+
8
+    S = State
9
+    A = Action
10
+
11
+  */
12
+
13
+  declare type Dispatch<A: { type: $Subtype<string> }> = (action: A) => A;
14
+
15
+  declare type MiddlewareAPI<S, A> = {
16
+    dispatch: Dispatch<A>;
17
+    getState(): S;
18
+  };
19
+
20
+  declare type Store<S, A> = {
21
+    // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
22
+    dispatch: Dispatch<A>;
23
+    getState(): S;
24
+    subscribe(listener: () => void): () => void;
25
+    replaceReducer(nextReducer: Reducer<S, A>): void
26
+  };
27
+
28
+  declare type Reducer<S, A> = (state: S, action: A) => S;
29
+
30
+  declare type Middleware<S, A> =
31
+    (api: MiddlewareAPI<S, A>) =>
32
+      (next: Dispatch<A>) => Dispatch<A>;
33
+
34
+  declare type StoreCreator<S, A> = {
35
+    (reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>;
36
+    (reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>;
37
+  };
38
+
39
+  declare type StoreEnhancer<S, A> = (next: StoreCreator<S, A>) => StoreCreator<S, A>;
40
+
41
+  declare function createStore<S, A>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>;
42
+  declare function createStore<S, A>(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>;
43
+
44
+  declare function applyMiddleware<S, A>(...middlewares: Array<Middleware<S, A>>): StoreEnhancer<S, A>;
45
+
46
+  declare type ActionCreator<A, B> = (...args: Array<B>) => A;
47
+  declare type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> };
48
+
49
+  declare function bindActionCreators<A, C: ActionCreator<A, any>>(actionCreator: C, dispatch: Dispatch<A>): C;
50
+  declare function bindActionCreators<A, K, C: ActionCreators<K, A>>(actionCreators: C, dispatch: Dispatch<A>): C;
51
+
52
+  declare function combineReducers<O: Object, A>(reducers: O): Reducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
53
+
54
+  declare function compose<S, A>(...fns: Array<StoreEnhancer<S, A>>): Function;
55
+
56
+}

+ 1
- 0
package.json 查看文件

60
     "clean-css": "^3.0.0",
60
     "clean-css": "^3.0.0",
61
     "css-loader": "*",
61
     "css-loader": "*",
62
     "eslint": "^3.14.1",
62
     "eslint": "^3.14.1",
63
+    "eslint-plugin-import": "^2.2.0",
63
     "eslint-plugin-jsdoc": "*",
64
     "eslint-plugin-jsdoc": "*",
64
     "eslint-plugin-react": "*",
65
     "eslint-plugin-react": "*",
65
     "eslint-plugin-react-native": "^2.2.1",
66
     "eslint-plugin-react-native": "^2.2.1",

+ 7
- 1
react/.eslintrc.js 查看文件

6
         }
6
         }
7
     },
7
     },
8
     'plugins': [
8
     'plugins': [
9
+
10
+        // ESLint's rule no-duplicate-imports does not understand Flow's import
11
+        // type. Fortunately, eslint-plugin-import understands Flow's import
12
+        // type.
13
+        'import',
9
         'jsdoc',
14
         'jsdoc',
10
         'react',
15
         'react',
11
         'react-native'
16
         'react-native'
273
         'no-confusing-arrow': 2,
278
         'no-confusing-arrow': 2,
274
         'no-const-assign': 2,
279
         'no-const-assign': 2,
275
         'no-dupe-class-members': 2,
280
         'no-dupe-class-members': 2,
276
-        'no-duplicate-imports': 2,
277
         'no-new-symbol': 2,
281
         'no-new-symbol': 2,
278
         'no-restricted-imports': 0,
282
         'no-restricted-imports': 0,
279
         'no-this-before-super': 2,
283
         'no-this-before-super': 2,
298
         'template-curly-spacing': 2,
302
         'template-curly-spacing': 2,
299
         'yield-star-spacing': 2,
303
         'yield-star-spacing': 2,
300
 
304
 
305
+        'import/no-duplicates': 2,
306
+
301
         // JsDoc plugin rules group. The following rules are in addition to
307
         // JsDoc plugin rules group. The following rules are in addition to
302
         // valid-jsdoc rule.
308
         // valid-jsdoc rule.
303
         'jsdoc/check-param-names': 0,
309
         'jsdoc/check-param-names': 0,

+ 11
- 8
react/features/base/redux/MiddlewareRegistry.js 查看文件

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
 import { applyMiddleware } from 'redux';
3
 import { applyMiddleware } from 'redux';
4
-
5
-type Middleware = Function;
4
+import type { Middleware } from 'redux';
6
 
5
 
7
 /**
6
 /**
8
  * A registry for Redux middleware, allowing features to register their
7
  * A registry for Redux middleware, allowing features to register their
9
  * middleware without needing to create additional inter-feature dependencies.
8
  * middleware without needing to create additional inter-feature dependencies.
10
  */
9
  */
11
 class MiddlewareRegistry {
10
 class MiddlewareRegistry {
12
-    _elements: Middleware[];
11
+    _elements: Array<Middleware<*, *>>;
13
 
12
 
14
     /**
13
     /**
15
      * Creates a MiddlewareRegistry instance.
14
      * Creates a MiddlewareRegistry instance.
19
          * The set of registered middleware.
18
          * The set of registered middleware.
20
          *
19
          *
21
          * @private
20
          * @private
22
-         * @type {Route[]}
21
+         * @type {Middleware[]}
23
          */
22
          */
24
         this._elements = [];
23
         this._elements = [];
25
     }
24
     }
32
      * be included (such as middleware from third-party modules).
31
      * be included (such as middleware from third-party modules).
33
      * @returns {Middleware}
32
      * @returns {Middleware}
34
      */
33
      */
35
-    applyMiddleware(...additional: Middleware[]) {
36
-        return applyMiddleware(
34
+    applyMiddleware(...additional: Array<Middleware<*, *>>) {
35
+        // XXX The explicit definition of the local variable middlewares is to
36
+        // satisfy flow.
37
+        const middlewares = [
37
             ...this._elements,
38
             ...this._elements,
38
             ...additional
39
             ...additional
39
-        );
40
+        ];
41
+
42
+        return applyMiddleware(...middlewares);
40
     }
43
     }
41
 
44
 
42
     /**
45
     /**
47
      * @param {Middleware} middleware - A Redux middleware.
50
      * @param {Middleware} middleware - A Redux middleware.
48
      * @returns {void}
51
      * @returns {void}
49
      */
52
      */
50
-    register(middleware: Middleware) {
53
+    register(middleware: Middleware<*, *>) {
51
         this._elements.push(middleware);
54
         this._elements.push(middleware);
52
     }
55
     }
53
 }
56
 }

Loading…
取消
儲存