diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 000000000..5a6f29e1a --- /dev/null +++ b/.flowconfig @@ -0,0 +1,19 @@ +[ignore] +/node_modules/fbjs/.* + +[include] + +[libs] + +[options] +module.use_strict=true +munge_underscores=true +suppress_comment= \\(.\\|\n\\)*\\$FlowDisableLine +suppress_comment= \\(.\\|\n\\)*\\$FlowBug +esproposal.class_static_fields=enable +esproposal.class_instance_fields=enable +esproposal.decorators=ignore +traces=3 + +[version] +>=0.25.0 diff --git a/.gitignore b/.gitignore index dbb9d4c83..e06c1bf7d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ node_modules npm-debug.log .DS_Store dist -lib +lib/* +!lib/index.js.flow coverage diff --git a/lib/index.js.flow b/lib/index.js.flow new file mode 100644 index 000000000..3041ab484 --- /dev/null +++ b/lib/index.js.flow @@ -0,0 +1,77 @@ +/* @flow */ +type ConnectAll = , SP, DP, Dispatch: Function>( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: (dispatch: Dispatch) => DP, + mergeProps: null | void, + options?: {pure?: boolean, withRef?: boolean} +) => (component: Class) => Class, SP>, S>> + +type ConnectAllStateless = ( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: (dispatch: Dispatch) => DP, + mergeProps: null | void, + options?: {pure?: boolean, withRef?: boolean} +) => (component: (props: P) => any) => Class, SP>, void>> + +type ConnectMerged = , SP, DP, MP, Dispatch: Function>( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: (dispatch: Dispatch) => DP, + mergeProps: (stateProps: SP, dispatchProps: DP, origProps: P) => MP, + options?: {pure?: boolean, withRef?: boolean} +) => (component: Class) => Class, S>> + +type ConnectMergedStateless = ( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: (dispatch: Dispatch) => DP, + mergeProps: (stateProps: SP, dispatchProps: DP, origProps: P) => MP, + options?: {pure?: boolean, withRef?: boolean} +) => (component: (props: P) => any) => Class, void>> + +type ConnectNoState = , DP, Dispatch: Function>( + mapStateToProps: null | void, + mapDispatchToProps: (dispatch: Dispatch) => DP, + mergeProps: null | void, + options?: {pure?: boolean, withRef?: boolean} + ) => (component: Class) => Class, S>> + +type ConnectNoStateStatless = ( + mapStateToProps: null | void, + mapDispatchToProps: (dispatch: Dispatch) => DP, + mergeProps: null | void, + options?: {pure?: boolean, withRef?: boolean} + ) => (component: (props: P) => any) => Class, void>> + +type ConnectDispatch = , SP, Dispatch: Function>( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: null | void, + mergeProps: null | void, + options?: {pure?: boolean, withRef?: boolean} +) => (component: Class) => Class, SP>, S>> + +type ConnectDispatchStateless = ( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: null | void, + mergeProps: null | void, + options?: {pure?: boolean, withRef?: boolean} +) => (component: (props: P) => any) => Class, SP>, void>> + +type ConnectDefault = , Dispatch: Function>() => + (component: Class) => Class, S>> + +type ConnectDefaultStateless = () => +

(component: (props: P) => any) => Class, void>> + +declare export var connect + : ConnectAll + & ConnectAllStateless + & ConnectMerged + & ConnectMergedStateless + & ConnectNoState + & ConnectNoStateStatless + & ConnectDispatch + & ConnectDispatchStateless + & ConnectDefault + & ConnectDefaultStateless; +declare export var Provider: ReactClass<{store: Object, children?: any}>; + +export {connect, Provider}