mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 14:38:20 +08:00
[redux-first-router] Update type definitions to v1.9 (#18562)
* Update redux-first-router typings with API changes as of v1.9.8 * Scrub trailing commas * Fix style of author declarations * Carefully exact-match typings to flow typings * Revert Params and Payload to object type
This commit is contained in:
committed by
Sheetal Nandi
parent
b7a538d41a
commit
c4e3656a59
63
types/redux-first-router/index.d.ts
vendored
63
types/redux-first-router/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for redux-first-router 1.4
|
||||
// Type definitions for redux-first-router 1.9
|
||||
// Project: https://github.com/faceyspacey/redux-first-router#readme
|
||||
// Definitions by: Valbrand <https://github.com/Valbrand>
|
||||
// viggyfresh <https://github.com/viggyfresh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -38,9 +39,23 @@ export interface RoutesMap {
|
||||
|
||||
export interface ReceivedAction {
|
||||
type: string;
|
||||
payload: object;
|
||||
payload: Payload;
|
||||
meta?: object;
|
||||
navKey?: string | null;
|
||||
query?: object;
|
||||
search?: string;
|
||||
navKey?: Nullable<string>;
|
||||
}
|
||||
|
||||
export interface ReceivedActionMeta {
|
||||
type: string;
|
||||
payload: Payload;
|
||||
query?: object;
|
||||
navKey?: Nullable<string>;
|
||||
meta: {
|
||||
notFoundPath?: string;
|
||||
query?: object;
|
||||
search?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface HistoryData {
|
||||
@@ -52,13 +67,17 @@ export interface HistoryData {
|
||||
export interface Location {
|
||||
pathname: string;
|
||||
type: string;
|
||||
payload: object;
|
||||
payload: Payload;
|
||||
query?: object;
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export interface LocationState {
|
||||
pathname: string;
|
||||
type: string;
|
||||
payload: object;
|
||||
payload: Payload;
|
||||
query?: object;
|
||||
search?: string;
|
||||
prev: Location;
|
||||
kind: Nullable<string>;
|
||||
history: Nullable<HistoryData>;
|
||||
@@ -80,7 +99,7 @@ export interface NavigationAction {
|
||||
routeName?: string;
|
||||
actions?: NavigationAction[];
|
||||
action?: NavigationAction;
|
||||
params?: object;
|
||||
params?: Params;
|
||||
meta?: object;
|
||||
}
|
||||
|
||||
@@ -88,17 +107,21 @@ export interface Meta {
|
||||
location: ActionMetaLocation;
|
||||
notFoundPath?: string;
|
||||
navigation?: NavigationAction;
|
||||
query?: object;
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export interface Action {
|
||||
type: string;
|
||||
payload: object;
|
||||
payload: Payload;
|
||||
meta: Meta;
|
||||
navKey?: string;
|
||||
query?: object;
|
||||
navKey?: Nullable<string>;
|
||||
}
|
||||
|
||||
export interface HistoryLocation {
|
||||
pathname: string;
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export type HistoryAction = string;
|
||||
@@ -110,7 +133,7 @@ export type ScrollBehavior = object;
|
||||
export interface Router {
|
||||
getStateForActionOriginal(action: object, state: Nullable<object>): Nullable<object>;
|
||||
getStateForAction(action: object, state: Nullable<object>): Nullable<object>;
|
||||
getPathAndParamsForState(state: object): { path: Nullable<string>, params: Nullable<object> };
|
||||
getPathAndParamsForState(state: object): { path: Nullable<string>, params: Nullable<Params> };
|
||||
getActionForPathAndParams(path: string): Nullable<object>;
|
||||
}
|
||||
|
||||
@@ -122,6 +145,14 @@ export interface Navigators {
|
||||
[key: string]: Navigator;
|
||||
}
|
||||
|
||||
export type SelectLocationState = (state: object) => LocationState;
|
||||
export type SelectTitleState = (state: object) => string;
|
||||
|
||||
export interface QuerySerializer {
|
||||
stringify(params: Params): string;
|
||||
parse(queryString: string): object;
|
||||
}
|
||||
|
||||
export interface NavigatorsConfig {
|
||||
navigators: Navigators;
|
||||
patchNavigators(navigators: Navigators): void;
|
||||
@@ -144,17 +175,22 @@ export interface NavigatorsConfig {
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
title?: string;
|
||||
location?: string;
|
||||
title?: string | SelectTitleState;
|
||||
location?: string | SelectLocationState;
|
||||
notFoundPath?: string;
|
||||
scrollTop?: boolean;
|
||||
onBeforeChange?<S>(dispatch: Dispatch<S>, getState: StateGetter): void;
|
||||
onAfterChange?<S>(dispatch: Dispatch<S>, getState: StateGetter): void;
|
||||
onBackNext?<S>(dispatch: Dispatch<S>, getState: StateGetter): void;
|
||||
restoreScroll?(history: History): ScrollBehavior;
|
||||
initialDispatch?: boolean;
|
||||
querySerializer?: QuerySerializer;
|
||||
navigators?: NavigatorsConfig;
|
||||
}
|
||||
|
||||
export type Params = object;
|
||||
export type Payload = object;
|
||||
|
||||
export type ScrollUpdater = (performedByUser: boolean) => void;
|
||||
|
||||
export const NOT_FOUND: string;
|
||||
@@ -170,10 +206,11 @@ export function canGoBack(): boolean;
|
||||
export function canGoForward(): boolean;
|
||||
|
||||
export function connectRoutes(history: History, routesMap: RoutesMap, options?: Options): {
|
||||
reducer: Reducer<LocationState>
|
||||
reducer: Reducer<LocationState>,
|
||||
middleware: Middleware,
|
||||
thunk<S>(store: Store<S>): Promise<Nullable<RouteThunk>>,
|
||||
enhancer: GenericStoreEnhancer
|
||||
enhancer: GenericStoreEnhancer,
|
||||
initialDispatch?(): void
|
||||
};
|
||||
|
||||
export function go(n: number): void;
|
||||
|
||||
@@ -26,8 +26,11 @@ const routesMap = {
|
||||
const {
|
||||
reducer,
|
||||
middleware,
|
||||
enhancer
|
||||
} = connectRoutes(history, routesMap);
|
||||
enhancer,
|
||||
initialDispatch
|
||||
} = connectRoutes(history, routesMap, {
|
||||
initialDispatch: false
|
||||
});
|
||||
|
||||
const dumbMiddleware: Middleware = (store: MiddlewareAPI<LocationState>) => (next: Dispatch<LocationState>) => (action: Action) => {
|
||||
next(action);
|
||||
|
||||
Reference in New Issue
Block a user