From ee9afde348be1a71a093c2dd275163cb6dcc2550 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 26 Jan 2016 03:46:45 +0300 Subject: [PATCH 1/3] added definitions for redux router --- redux-router/redux-router.d.ts | 109 +++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 redux-router/redux-router.d.ts diff --git a/redux-router/redux-router.d.ts b/redux-router/redux-router.d.ts new file mode 100644 index 000000000..2f55e13ee --- /dev/null +++ b/redux-router/redux-router.d.ts @@ -0,0 +1,109 @@ +// Type definitions for redux-router v1.0.0 +// Project: https://github.com/rackt/redux-router +// Definitions by: Stepan Mikhaylyuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// +/// + +declare namespace __ReduxRouter { + + import React = __React; + import H = HistoryModule; + /** + * A component that renders a React Router app using router state from a Redux store. + */ + export class ReduxRouter extends React.Component { new(); } + /** + * A component that renders a React Router app using router state from a Redux store. + */ + export class ReactRouter { } + /** + * A Redux store enhancer that adds router state to the store. + */ + export var reduxReactRouter: any; + + export function isActive(pathname: H.Pathname, query?: H.Query, indexOnly?: boolean): boolean; + /** + * A reducer that keeps track of Router state. + */ + export function routerStateReducer(state: any, action: any): any; + + export interface ReduxRouterAction { + type: string, + payload: any + } + + export function routerDidChange(state): ReduxRouterAction; + export function initRoutes(routes): ReduxRouterAction; + export function replaceRoutes(routes): ReduxRouterAction; + export function historyAPI(method): ReduxRouterAction; +} + +declare module "redux-router/lib/routerStateReducer" { + export default __ReduxRouter.routerStateReducer; +} + +declare module "redux-router/lib/ReduxRouter" { + export default __ReduxRouter.ReactRouter; +} + +declare module "redux-router/lib/client" { + export default __ReduxRouter.reduxReactRouter; +} + +declare module "redux-router/lib/isActive" { + export default __ReduxRouter.isActive; +} + +declare module "redux-router/lib/actionCreators" { + export const routerDidChange: typeof __ReduxRouter.routerDidChange; + export const initRoutes: typeof __ReduxRouter.initRoutes; + export const replaceRoutes: typeof __ReduxRouter.replaceRoutes; + export const historyAPI: typeof __ReduxRouter.historyAPI; + export const pushState: __ReduxRouter.ReduxRouterAction; + export const push: __ReduxRouter.ReduxRouterAction; + export const replaceState: __ReduxRouter.ReduxRouterAction; + export const replace: __ReduxRouter.ReduxRouterAction; + export const setState: __ReduxRouter.ReduxRouterAction; + export const go: __ReduxRouter.ReduxRouterAction; + export const goBack: __ReduxRouter.ReduxRouterAction; + export const goForward: __ReduxRouter.ReduxRouterAction; +} + +declare module "redux-router" { + + import routerStateReducer from "redux-router/lib/routerStateReducer"; + import ReduxRouter from "redux-router/lib/ReduxRouter"; + import reduxReactRouter from "redux-router/lib/client"; + import isActive from "redux-router/lib/isActive"; + + import { + historyAPI, + pushState, + push, + replaceState, + replace, + setState, + go, + goBack, + goForward + } from "redux-router/lib/actionCreators"; + + export { + routerStateReducer, + ReduxRouter, + reduxReactRouter, + isActive, + historyAPI, + pushState, + push, + replaceState, + replace, + setState, + go, + goBack, + goForward + } +} From 75417d40877d2f552d5e23cb46808fcf8f1d2361 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 26 Jan 2016 03:50:06 +0300 Subject: [PATCH 2/3] added tests for redux router definitions --- redux-router/redux-router-tests.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 redux-router/redux-router-tests.ts diff --git a/redux-router/redux-router-tests.ts b/redux-router/redux-router-tests.ts new file mode 100644 index 000000000..081f94d71 --- /dev/null +++ b/redux-router/redux-router-tests.ts @@ -0,0 +1,2 @@ +/// +import { reduxReactRouter, routerStateReducer, ReduxRouter } from 'redux-router'; From 7139bce6dabae7a557f4068e977d6e84bcad043a Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 26 Jan 2016 04:01:56 +0300 Subject: [PATCH 3/3] minor fixes --- redux-router/redux-router.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/redux-router/redux-router.d.ts b/redux-router/redux-router.d.ts index 2f55e13ee..3bd7b0e7b 100644 --- a/redux-router/redux-router.d.ts +++ b/redux-router/redux-router.d.ts @@ -14,7 +14,7 @@ declare namespace __ReduxRouter { /** * A component that renders a React Router app using router state from a Redux store. */ - export class ReduxRouter extends React.Component { new(); } + export class ReduxRouter extends React.Component { } /** * A component that renders a React Router app using router state from a Redux store. */ @@ -35,10 +35,10 @@ declare namespace __ReduxRouter { payload: any } - export function routerDidChange(state): ReduxRouterAction; - export function initRoutes(routes): ReduxRouterAction; - export function replaceRoutes(routes): ReduxRouterAction; - export function historyAPI(method): ReduxRouterAction; + export function routerDidChange(state: any): ReduxRouterAction; + export function initRoutes(routes: any): ReduxRouterAction; + export function replaceRoutes(routes: any): ReduxRouterAction; + export function historyAPI(method: any): ReduxRouterAction; } declare module "redux-router/lib/routerStateReducer" {