-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
add flow type definition file #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ignore] | ||
<PROJECT_ROOT>/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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ node_modules | |
npm-debug.log | ||
.DS_Store | ||
dist | ||
lib | ||
lib/* | ||
!lib/index.js.flow | ||
coverage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* @flow */ | ||
type ConnectAll = <D, P, S, C: React$Component<D, P, S>, SP, DP, Dispatch: Function>( | ||
mapStateToProps: (state: Object) => SP, | ||
mapDispatchToProps: (dispatch: Dispatch) => DP, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An important case that we want to support is when
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
mergeProps: null | void, | ||
options?: {pure?: boolean, withRef?: boolean} | ||
) => (component: Class<C>) => Class<React$Component<D, $Diff<$Diff<P, DP>, SP>, S>> | ||
|
||
type ConnectAllStateless = <P, SP, DP, Dispatch: Function>( | ||
mapStateToProps: (state: Object) => SP, | ||
mapDispatchToProps: (dispatch: Dispatch) => DP, | ||
mergeProps: null | void, | ||
options?: {pure?: boolean, withRef?: boolean} | ||
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<$Diff<P, DP>, SP>, void>> | ||
|
||
type ConnectMerged = <D, P, S, C: React$Component<D, P, S>, 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<C>) => Class<React$Component<D, $Diff<P, MP>, S>> | ||
|
||
type ConnectMergedStateless = <P, 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: (props: P) => any) => Class<React$Component<void, $Diff<P, MP>, void>> | ||
|
||
type ConnectNoState = <D, P, S, C: React$Component<D, P, S>, DP, Dispatch: Function>( | ||
mapStateToProps: null | void, | ||
mapDispatchToProps: (dispatch: Dispatch) => DP, | ||
mergeProps: null | void, | ||
options?: {pure?: boolean, withRef?: boolean} | ||
) => (component: Class<C>) => Class<React$Component<D, $Diff<P, DP>, S>> | ||
|
||
type ConnectNoStateStatless = <P, DP, Dispatch: Function>( | ||
mapStateToProps: null | void, | ||
mapDispatchToProps: (dispatch: Dispatch) => DP, | ||
mergeProps: null | void, | ||
options?: {pure?: boolean, withRef?: boolean} | ||
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<P, DP>, void>> | ||
|
||
type ConnectDispatch = <D, P, S, C: React$Component<D, P, S>, SP, Dispatch: Function>( | ||
mapStateToProps: (state: Object) => SP, | ||
mapDispatchToProps: null | void, | ||
mergeProps: null | void, | ||
options?: {pure?: boolean, withRef?: boolean} | ||
) => (component: Class<C>) => Class<React$Component<D, $Diff<$Diff<P, {dispatch: Dispatch}>, SP>, S>> | ||
|
||
type ConnectDispatchStateless = <P, SP, Dispatch: Function>( | ||
mapStateToProps: (state: Object) => SP, | ||
mapDispatchToProps: null | void, | ||
mergeProps: null | void, | ||
options?: {pure?: boolean, withRef?: boolean} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think options are always forced to be the last argument. (I wanted to make passing them inconvenient because they enable escape hatches like Only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I didn't know that. Still the overloads are still needed because every combination changes the type of the returned value. Every overload in the file has a different return type! I'll change the type defs though. |
||
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<$Diff<P, {dispatch: Dispatch}>, SP>, void>> | ||
|
||
type ConnectDefault = <D, P, S, C: React$Component<D, P, S>, Dispatch: Function>() => | ||
(component: Class<C>) => Class<React$Component<D, $Diff<P, {dispatch: Dispatch}>, S>> | ||
|
||
type ConnectDefaultStateless = () => | ||
<P>(component: (props: P) => any) => Class<React$Component<void, $Diff<P, {dispatch: Function}>, 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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapStateToProps can have additional parameter - own props of the connected component.