From 7e4acd4d0f4895aea0f47bda4e371ba36cd697cd Mon Sep 17 00:00:00 2001 From: "Goel, Naman" Date: Tue, 24 May 2016 01:30:16 -0700 Subject: [PATCH 1/2] add flow type definition file --- .flowconfig | 19 +++++++++++++ .gitignore | 3 ++- lib/index.js.flow | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .flowconfig create mode 100644 lib/index.js.flow 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..8638e6d67 --- /dev/null +++ b/lib/index.js.flow @@ -0,0 +1,69 @@ +/* @flow */ +type ConnectAll = , SP, DP, Dispatch: Function>( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: (dispatch: Dispatch) => DP, + options?: {pure?: boolean, withRef?: boolean} +) => (component: Class) => Class, SP>, S>> + +type ConnectAllStateless = ( + mapStateToProps: (state: Object) => SP, + mapDispatchToProps: (dispatch: Dispatch) => DP, + 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, + options?: {pure?: boolean, withRef?: boolean} + ) => (component: Class) => Class, S>> + +type ConnectNoStateStatless = ( + mapStateToProps: null | void, + mapDispatchToProps: (dispatch: Dispatch) => DP, + options?: {pure?: boolean, withRef?: boolean} + ) => (component: (props: P) => any) => Class, void>> + +type ConnectDisptch = , SP, Dispatch: Function>( + mapStateToProps: (state: Object) => SP, + options?: {pure?: boolean, withRef?: boolean} +) => (component: Class) => Class, SP>, S>> + +type ConnectDisptchStateless = ( + mapStateToProps: (state: Object) => SP, + 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 + & ConnectDisptch + & ConnectDisptchStateless + & ConnectDefault + & ConnectDefaultStateless; +declare export var Provider: ReactClass<{store: Object, children?: any}>; + +export {connect, Provider} From 2d0a79b4955ab9fec3aa26d93df397689971cfb3 Mon Sep 17 00:00:00 2001 From: "Goel, Naman" Date: Sat, 4 Jun 2016 21:50:15 -0700 Subject: [PATCH 2/2] fix typos, argument signature --- lib/index.js.flow | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/index.js.flow b/lib/index.js.flow index 8638e6d67..3041ab484 100644 --- a/lib/index.js.flow +++ b/lib/index.js.flow @@ -2,12 +2,14 @@ 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>> @@ -28,22 +30,28 @@ type ConnectMergedStateless = ( 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 ConnectDisptch = , SP, Dispatch: Function>( +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 ConnectDisptchStateless = ( +type ConnectDispatchStateless = ( mapStateToProps: (state: Object) => SP, + mapDispatchToProps: null | void, + mergeProps: null | void, options?: {pure?: boolean, withRef?: boolean} ) => (component: (props: P) => any) => Class, SP>, void>> @@ -60,8 +68,8 @@ declare export var connect & ConnectMergedStateless & ConnectNoState & ConnectNoStateStatless - & ConnectDisptch - & ConnectDisptchStateless + & ConnectDispatch + & ConnectDispatchStateless & ConnectDefault & ConnectDefaultStateless; declare export var Provider: ReactClass<{store: Object, children?: any}>;