From c3545db618098defce0d82cb5ebe742c23b1bfe2 Mon Sep 17 00:00:00 2001 From: Mykolas Kairys Date: Thu, 15 Mar 2018 14:21:40 +0200 Subject: [PATCH 1/2] react-router-redux typings update for createMatchSelector function --- types/react-router-redux/index.d.ts | 4 ++++ types/react-router-redux/react-router-redux-tests.tsx | 6 +++++- types/react-router-redux/tslint.json | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/react-router-redux/index.d.ts b/types/react-router-redux/index.d.ts index 0ce965b397..89ef136014 100644 --- a/types/react-router-redux/index.d.ts +++ b/types/react-router-redux/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux // Definitions by: Huy Nguyen // Shoya Tanaka +// Mykolas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -19,6 +20,7 @@ import { LocationDescriptor } from 'history'; import * as React from 'react'; +import { match } from 'react-router'; export interface ConnectedRouterProps { store?: Store; @@ -77,3 +79,5 @@ export interface LocationChangeAction { } export function routerMiddleware(history: History): Middleware; + +export function createMatchSelector(path: string): (state: State) => match | null; diff --git a/types/react-router-redux/react-router-redux-tests.tsx b/types/react-router-redux/react-router-redux-tests.tsx index b6927fb7bf..bf2575ae26 100644 --- a/types/react-router-redux/react-router-redux-tests.tsx +++ b/types/react-router-redux/react-router-redux-tests.tsx @@ -7,7 +7,7 @@ import { Provider } from 'react-redux'; import createHistory from 'history/createBrowserHistory'; import { Route } from 'react-router'; -import { ConnectedRouter, routerReducer, routerMiddleware, push, RouterState } from 'react-router-redux'; +import { ConnectedRouter, routerReducer, routerMiddleware, push, RouterState, createMatchSelector } from 'react-router-redux'; // Create a history of your choosing (we're using a browser history in this case) const history = createHistory(); @@ -44,3 +44,7 @@ ReactDOM.render( // Now you can dispatch navigation actions from anywhere! store.dispatch(push('/foo')); + +// And match location path using createMatchSelector +const matchSelector = createMatchSelector('/:foo'); +const match = matchSelector(store.getState()); diff --git a/types/react-router-redux/tslint.json b/types/react-router-redux/tslint.json index f93cf8562a..71ee04c4e1 100644 --- a/types/react-router-redux/tslint.json +++ b/types/react-router-redux/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } From 026dc969c2cf6077a21271d37cc3c912fa43be89 Mon Sep 17 00:00:00 2001 From: Mykolas Kairys Date: Wed, 28 Mar 2018 11:24:08 +0300 Subject: [PATCH 2/2] updated react-router-redux createMatchSelector definition to not have generic --- types/react-router-redux/index.d.ts | 2 +- types/react-router-redux/tslint.json | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/types/react-router-redux/index.d.ts b/types/react-router-redux/index.d.ts index 89ef136014..7c8d78ccc9 100644 --- a/types/react-router-redux/index.d.ts +++ b/types/react-router-redux/index.d.ts @@ -80,4 +80,4 @@ export interface LocationChangeAction { export function routerMiddleware(history: History): Middleware; -export function createMatchSelector(path: string): (state: State) => match | null; +export function createMatchSelector(path: string): (state: { router: RouterState }) => match<{}> | null; diff --git a/types/react-router-redux/tslint.json b/types/react-router-redux/tslint.json index 71ee04c4e1..f93cf8562a 100644 --- a/types/react-router-redux/tslint.json +++ b/types/react-router-redux/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-unnecessary-generics": false - } + "extends": "dtslint/dt.json" }