Skip to content

Instantly share code, notes, and snippets.

@aikoven
Created February 17, 2016 06:59
Show Gist options
  • Save aikoven/be8a430ab2a38baaf29f to your computer and use it in GitHub Desktop.
Save aikoven/be8a430ab2a38baaf29f to your computer and use it in GitHub Desktop.
// Type definitions for react-redux 2.1.2
// Project: https://github.com/rackt/react-redux
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
/// <reference path="../redux/redux.d.ts" />
declare module "react-redux" {
import { Component, ComponentClass, StatelessComponent } from 'react';
import { Store, Dispatch, ActionCreator } from 'redux';
export interface ClassDecorator<P, O> {
//(component: ComponentClass<any>): ComponentClass<any>;
(component: StatelessComponent<P>): ComponentClass<O>;
}
/**
* Connects a React component to a Redux store.
* @param mapStateToProps
* @param mapDispatchToProps
* @param mergeProps
* @param options
*/
export function connect<O, S, D, P>(
mapStateToProps: MapStateToProps<O, S>,
mapDispatchToProps: MapDispatchToPropsFunction<D, O>|D,
mergeProps: MergeProps<S, D, O, P>,
options?: Options): ClassDecorator<P, O>;
export function connect<O, S, D>(
mapStateToProps?: MapStateToProps<O, S>,
mapDispatchToProps?: MapDispatchToPropsFunction<O, D>|D
): ClassDecorator<O & S & D, O>;
export interface MapStateToProps<O, S> {
(state: any, ownProps?: O): S;
}
export interface MapDispatchToPropsFunction<O, D> {
(dispatch: Dispatch, ownProps?: O): D;
}
export interface MergeProps<S, D, O, P> {
(stateProps: S, dispatchProps: D, ownProps: O): P;
}
export interface Options {
/**
* If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps,
* preventing unnecessary updates, assuming that the component is a “pure” component
* and does not rely on any input or state other than its props and the selected Redux store’s state.
* Defaults to true.
* @default true
*/
pure: boolean;
}
export interface Property {
/**
* The single Redux store in your application.
*/
store?: Store<any>;
children?: Function;
}
/**
* Makes the Redux store available to the connect() calls in the component hierarchy below.
*/
export class Provider extends Component<Property, {}> { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment