Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving return types of action creators by adding generic args type #243

Merged
merged 2 commits into from
Feb 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ declare module 'connected-react-router' {
payload: RouterState;
}

export interface CallHistoryMethodAction {
export interface CallHistoryMethodAction<A = any[]> {
type: typeof CALL_HISTORY_METHOD;
payload: LocationActionPayload;
payload: LocationActionPayload<A>;
}

export interface RouterRootState {
Expand All @@ -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<S = LocationState>(location: LocationDescriptorObject<S>): CallHistoryMethodAction<[ LocationDescriptorObject<S> ]>;
export function replace(path: Path, state?: LocationState): CallHistoryMethodAction<[ Path, LocationState? ]>;
export function replace<S = LocationState>(location: LocationDescriptorObject<S>): CallHistoryMethodAction<[ LocationDescriptorObject<S> ]>;
export function go(n: number): CallHistoryMethodAction<[ number ]>;
export function goBack(): CallHistoryMethodAction<[]>;
export function goForward(): CallHistoryMethodAction<[]>;
export function getRouter<S extends RouterRootState>(state: S): RouterState;
export function getAction<S extends RouterRootState>(state: S): RouterActionType;
export function getHash<S extends RouterRootState>(state: S): string;
Expand All @@ -74,9 +74,9 @@ declare module 'connected-react-router' {
goForward: GoForward;
};

export interface LocationActionPayload {
export interface LocationActionPayload<A = any[]> {
method: string;
args?: any[];
args?: A;
}

export class ConnectedRouter extends React.Component<
Expand Down