-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic use cases for connect covered * support dispatch * understand passing object as action creators * mapDispatchToProps can be null * mergeProps * get rid of extra dispatches * enhance dispatchers as object tests * mapDispatchToProps can be null * accept ConnectOptions * remove unused declarations * cleanup and unify type prop naming * set lower bound to 0.57.1 * fine tune tests * Support default props Support Stateless functional components * set proper Flow versions * enhance connect options * fix libdef test issue * test react-redux with exact props * fix typo
- Loading branch information
1 parent
6475dcc
commit dcd1531
Showing
6 changed files
with
425 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
95 changes: 95 additions & 0 deletions
95
definitions/npm/react-redux_v5.x.x/flow_v0.62.0-/react-redux_v5.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import type { Dispatch, Store } from "redux"; | ||
|
||
declare module "react-redux" { | ||
import type { ComponentType, ElementConfig } from 'react'; | ||
|
||
declare export class Provider<S, A> extends React$Component<{ | ||
store: Store<S, A>, | ||
children?: any | ||
}> {} | ||
|
||
declare export function createProvider( | ||
storeKey?: string, | ||
subKey?: string | ||
): Provider<*, *>; | ||
|
||
/* | ||
S = State | ||
A = Action | ||
OP = OwnProps | ||
SP = StateProps | ||
DP = DispatchProps | ||
MP = Merge props | ||
MDP = Map dispatch to props object | ||
RSP = Returned state props | ||
RDP = Returned dispatch props | ||
RMP = Returned merge props | ||
Com = React Component | ||
*/ | ||
|
||
declare type MapStateToProps<SP: Object, RSP: Object> = (state: Object, props: SP) => RSP; | ||
|
||
declare type MapDispatchToProps<A, OP: Object, RDP: Object> = (dispatch: Dispatch<A>, ownProps: OP) => RDP; | ||
|
||
declare type MergeProps<SP: Object, DP: Object, MP: Object, RMP: Object> = ( | ||
stateProps: SP, | ||
dispatchProps: DP, | ||
ownProps: MP | ||
) => RMP; | ||
|
||
declare type ConnectOptions<S: Object, OP: Object, RSP: Object, RMP: Object> = {| | ||
pure?: boolean, | ||
withRef?: boolean, | ||
areStatesEqual?: (next: S, prev: S) => boolean, | ||
areOwnPropsEqual?: (next: OP, prev: OP) => boolean, | ||
areStatePropsEqual?: (next: RSP, prev: RSP) => boolean, | ||
areMergedPropsEqual?: (next: RMP, prev: RMP) => boolean, | ||
storeKey?: string | ||
|}; | ||
|
||
declare type OmitDispatch<Component> = $Diff<Component, {dispatch: Dispatch<*>}>; | ||
|
||
declare export function connect<Com: ComponentType<*>, DP: Object, RSP: Object>( | ||
mapStateToProps: MapStateToProps<DP, RSP>, | ||
mapDispatchToProps?: null | ||
): (component: Com) => ComponentType<$Diff<OmitDispatch<ElementConfig<Com>>, RSP> & DP>; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
villesau
Author
Member
|
||
|
||
declare export function connect<Com: ComponentType<*>>( | ||
mapStateToProps?: null, | ||
mapDispatchToProps?: null | ||
): (component: Com) => ComponentType<OmitDispatch<ElementConfig<Com>>>; | ||
|
||
declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object>( | ||
mapStateToProps: MapStateToProps<SP, RSP>, | ||
mapDispatchToProps: MapDispatchToProps<A, DP, RDP> | ||
): (component: Com) => ComponentType<$Diff<$Diff<ElementConfig<Com>, RSP>, RDP> & SP & DP>; | ||
|
||
declare export function connect<Com: ComponentType<*>, A, OP: Object, DP: Object,PR: Object>( | ||
mapStateToProps?: null, | ||
mapDispatchToProps: MapDispatchToProps<A, OP, DP> | ||
): (Com) => ComponentType<$Diff<ElementConfig<Com>, DP> & OP>; | ||
|
||
declare export function connect<Com: ComponentType<*>, MDP: Object>( | ||
mapStateToProps?: null, | ||
mapDispatchToProps: MDP | ||
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>>; | ||
|
||
declare export function connect<Com: ComponentType<*>, SP: Object, RSP: Object, MDP: Object>( | ||
mapStateToProps: MapStateToProps<SP, RSP>, | ||
mapDispatchToPRops: MDP | ||
): (component: Com) => ComponentType<$Diff<$Diff<ElementConfig<Com>, RSP>, MDP> & SP>; | ||
|
||
declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object, MP: Object, RMP: Object>( | ||
mapStateToProps: MapStateToProps<SP, RSP>, | ||
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>, | ||
mergeProps: MergeProps<RSP, RDP, MP, RMP> | ||
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>; | ||
|
||
declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object, MP: Object, RMP: Object>( | ||
mapStateToProps: ?MapStateToProps<SP, RSP>, | ||
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>, | ||
mergeProps: ?MergeProps<RSP, RDP, MP, RMP>, | ||
options: ConnectOptions<*, SP & DP & MP, RSP, RMP> | ||
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>; | ||
} |
11 changes: 11 additions & 0 deletions
11
definitions/npm/react-redux_v5.x.x/flow_v0.62.0-/test_Provider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @flow | ||
import React from "react"; | ||
import { Provider, createProvider } from "react-redux"; | ||
|
||
// $ExpectError | ||
<Provider />; // missing store | ||
|
||
const CustomProvider: Provider<*, *> = createProvider("ikea"); | ||
|
||
// $ExpectError | ||
<CustomProvider />; // missing store |
Oops, something went wrong.
Hi, why do you force using
ComponentType
instead ofComponent
here?@villesau