From 4d45563586e6dc885a77e6f136152e2577dabf29 Mon Sep 17 00:00:00 2001 From: Leo Salgueiro Date: Mon, 21 Jan 2019 20:36:59 -0800 Subject: [PATCH 1/2] improving return types of action creators --- index.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/index.d.ts b/index.d.ts index 41053ebb..00bc6002 100644 --- a/index.d.ts +++ b/index.d.ts @@ -29,9 +29,9 @@ declare module 'connected-react-router' { payload: RouterState; } - export interface CallHistoryMethodAction { + export interface CallHistoryMethodAction { type: typeof CALL_HISTORY_METHOD; - payload: LocationActionPayload; + payload: LocationActionPayload; } export interface RouterRootState { @@ -44,13 +44,13 @@ declare module 'connected-react-router' { export type RouterAction = LocationChangeAction | CallHistoryMethodAction; - export function push(path: Path, state?: LocationState): CallHistoryMethodAction; - export function push(location: LocationDescriptorObject): CallHistoryMethodAction; - export function replace(path: Path, state?: LocationState): CallHistoryMethodAction; - export function replace(location: LocationDescriptorObject): CallHistoryMethodAction; - export function go(n: number): CallHistoryMethodAction; - export function goBack(): CallHistoryMethodAction; - export function goForward(): CallHistoryMethodAction; + export function push(path: Path, state?: LocationState): CallHistoryMethodAction<[ Path, LocationState? ]>; + export function push(location: LocationDescriptorObject): CallHistoryMethodAction<[ LocationDescriptorObject ]>; + export function replace(path: Path, state?: LocationState): CallHistoryMethodAction<[ Path, LocationState? ]>; + export function replace(location: LocationDescriptorObject): CallHistoryMethodAction<[ LocationDescriptorObject ]>; + export function go(n: number): CallHistoryMethodAction<[ number ]>; + export function goBack(): CallHistoryMethodAction<[]>; + export function goForward(): CallHistoryMethodAction<[]>; export function getRouter(state: S): RouterState; export function getAction(state: S): RouterActionType; export function getHash(state: S): string; @@ -74,9 +74,9 @@ declare module 'connected-react-router' { goForward: GoForward; }; - export interface LocationActionPayload { + export interface LocationActionPayload { method: string; - args?: any[]; + args?: A; } export class ConnectedRouter extends React.Component< From 00bea3e91ea8df64aa2d95a4a5e223d3f65e58ff Mon Sep 17 00:00:00 2001 From: Leo Salgueiro Date: Wed, 6 Feb 2019 06:42:15 -0800 Subject: [PATCH 2/2] adding generics to make sure the changes are backwards compatible --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 00bc6002..5a332a6d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -29,7 +29,7 @@ declare module 'connected-react-router' { payload: RouterState; } - export interface CallHistoryMethodAction { + export interface CallHistoryMethodAction { type: typeof CALL_HISTORY_METHOD; payload: LocationActionPayload; } @@ -74,7 +74,7 @@ declare module 'connected-react-router' { goForward: GoForward; }; - export interface LocationActionPayload { + export interface LocationActionPayload { method: string; args?: A; }