Skip to content

Commit 2c059c4

Browse files
fix(redirectTo): fix TS type signature of redirectTo
relates to #3117
1 parent 0948309 commit 2c059c4

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/common/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const noop = () => <any> undefined;
2424

2525
export type Mapper<X, T> = (x: X, key?: (string|number)) => T;
2626
export interface TypedMap<T> { [key: string]: T; }
27-
export type Predicate<X> = (x: X) => boolean;
27+
export type Predicate<X> = (x?: X) => boolean;
2828
export type IInjectable = (Function|any[]);
2929

3030
export interface Obj extends Object {

src/params/interface.ts

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import {ParamType} from "./type";
55
* Parameter values
66
*
77
* An object containing state parameter key/value pairs
8+
*
9+
* #### Example:
10+
* ```js
11+
* {
12+
* userId: 353474,
13+
* folderId: 'inbox'
14+
* }
15+
* ```
816
*/
917
export interface RawParams {
1018
[key: string]: any;

src/state/interface.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @module state */ /** for typedoc */
2-
import {ParamDeclaration} from "../params/interface";
2+
import { ParamDeclaration, RawParams } from "../params/interface";
33

44
import {State} from "./stateObject";
55
import {ViewContext} from "../view/interface";
@@ -66,6 +66,15 @@ export interface _ViewDeclaration {
6666
$context?: ViewContext;
6767
}
6868

69+
/**
70+
* The return value of a [[redirectTo]] function
71+
*
72+
* - string: a state name
73+
* - TargetState: a target state, parameters, and options
74+
* - object: an object with a state name and parameters
75+
*/
76+
export type RedirectToResult = string | TargetState | { state?: string, params?: RawParams };
77+
6978
/**
7079
* The StateDeclaration object is used to define a state or nested state.
7180
*
@@ -431,10 +440,7 @@ export interface StateDeclaration {
431440
* })
432441
* ```
433442
*/
434-
redirectTo?: ( string |
435-
(($transition$: Transition) => TargetState) |
436-
{ state: (string|StateDeclaration), params: { [key: string]: any }}
437-
)
443+
redirectTo?: RedirectToResult | Promise<RedirectToResult>
438444

439445
/**
440446
* A Transition Hook called with the state is being entered. See: [[IHookRegistry.onEnter]]

0 commit comments

Comments
 (0)