mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-13 08:57:26 +08:00
[react-redux] Do not mark ownProps as optional
According to docs, "it's always legal to provide a callback that accepts fewer arguments": https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#optional-parameters-in-callbacks Morever, react-redux docs say that ownProps will have a value when it is specified as a callback argument: https://github.com/reactjs/react-redux/blob/master/docs/api.md#the-arity-of-mapstatetoprops-and-mapdispatchtoprops-determines-whether-they-receive-ownprops
This commit is contained in:
9
types/react-redux/index.d.ts
vendored
9
types/react-redux/index.d.ts
vendored
@@ -5,6 +5,7 @@
|
||||
// Thomas Hasner <https://github.com/thasner>,
|
||||
// Kenzie Togami <https://github.com/kenzierocks>,
|
||||
// Curits Layne <https://github.com/clayne11>
|
||||
// Frank Tan <https://github.com/tansongyang>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -134,17 +135,17 @@ export declare function connect<TStateProps, TDispatchProps, TOwnProps, TMergedP
|
||||
): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
|
||||
|
||||
interface MapStateToProps<TStateProps, TOwnProps> {
|
||||
(state: any, ownProps?: TOwnProps): TStateProps;
|
||||
(state: any, ownProps: TOwnProps): TStateProps;
|
||||
}
|
||||
|
||||
interface MapStateToPropsFactory<TStateProps, TOwnProps> {
|
||||
(initialState: any, ownProps?: TOwnProps): MapStateToProps<TStateProps, TOwnProps>;
|
||||
(initialState: any, ownProps: TOwnProps): MapStateToProps<TStateProps, TOwnProps>;
|
||||
}
|
||||
|
||||
type MapStateToPropsParam<TStateProps, TOwnProps> = MapStateToProps<TStateProps, TOwnProps> | MapStateToPropsFactory<TStateProps, TOwnProps>;
|
||||
|
||||
interface MapDispatchToPropsFunction<TDispatchProps, TOwnProps> {
|
||||
(dispatch: Dispatch<any>, ownProps?: TOwnProps): TDispatchProps;
|
||||
(dispatch: Dispatch<any>, ownProps: TOwnProps): TDispatchProps;
|
||||
}
|
||||
|
||||
interface MapDispatchToPropsObject {
|
||||
@@ -155,7 +156,7 @@ type MapDispatchToProps<TDispatchProps, TOwnProps> =
|
||||
MapDispatchToPropsFunction<TDispatchProps, TOwnProps> | MapDispatchToPropsObject;
|
||||
|
||||
interface MapDispatchToPropsFactory<TDispatchProps, TOwnProps> {
|
||||
(dispatch: Dispatch<any>, ownProps?: TOwnProps): MapDispatchToProps<TDispatchProps, TOwnProps>;
|
||||
(dispatch: Dispatch<any>, ownProps: TOwnProps): MapDispatchToProps<TDispatchProps, TOwnProps>;
|
||||
}
|
||||
|
||||
type MapDispatchToPropsParam<TDispatchProps, TOwnProps> = MapDispatchToProps<TDispatchProps, TOwnProps> | MapDispatchToPropsFactory<TDispatchProps, TOwnProps>;
|
||||
|
||||
@@ -63,8 +63,8 @@ connect<ICounterStateProps, ICounterDispatchProps, {}>(
|
||||
)(Counter);
|
||||
// with higher order functions using parameters
|
||||
connect<ICounterStateProps, ICounterDispatchProps, {}>(
|
||||
(initialState: CounterState, ownProps: {}) => mapStateToProps,
|
||||
(dispatch: Dispatch<CounterState>, ownProps: {}) => mapDispatchToProps
|
||||
(initialState: CounterState, ownProps) => mapStateToProps,
|
||||
(dispatch: Dispatch<CounterState>, ownProps) => mapDispatchToProps
|
||||
)(Counter);
|
||||
// only first argument
|
||||
connect<ICounterStateProps, {}, {}>(
|
||||
|
||||
Reference in New Issue
Block a user