diff --git a/src/common/common.ts b/src/common/common.ts index c9880e66..1357c7c7 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -24,7 +24,7 @@ export const noop = () => undefined; export type Mapper = (x: X, key?: (string|number)) => T; export interface TypedMap { [key: string]: T; } -export type Predicate = (x: X) => boolean; +export type Predicate = (x?: X) => boolean; export type IInjectable = (Function|any[]); export interface Obj extends Object { diff --git a/src/params/interface.ts b/src/params/interface.ts index be9a13c2..4a47cd9b 100644 --- a/src/params/interface.ts +++ b/src/params/interface.ts @@ -5,6 +5,14 @@ import {ParamType} from "./type"; * Parameter values * * An object containing state parameter key/value pairs + * + * #### Example: + * ```js + * { + * userId: 353474, + * folderId: 'inbox' + * } + * ``` */ export interface RawParams { [key: string]: any; diff --git a/src/state/interface.ts b/src/state/interface.ts index 3d4648ba..8e7712b9 100644 --- a/src/state/interface.ts +++ b/src/state/interface.ts @@ -1,5 +1,5 @@ /** @module state */ /** for typedoc */ -import {ParamDeclaration} from "../params/interface"; +import { ParamDeclaration, RawParams } from "../params/interface"; import {State} from "./stateObject"; import {ViewContext} from "../view/interface"; @@ -66,6 +66,15 @@ export interface _ViewDeclaration { $context?: ViewContext; } +/** + * The return value of a [[redirectTo]] function + * + * - string: a state name + * - TargetState: a target state, parameters, and options + * - object: an object with a state name and parameters + */ +export type RedirectToResult = string | TargetState | { state?: string, params?: RawParams }; + /** * The StateDeclaration object is used to define a state or nested state. * @@ -431,10 +440,7 @@ export interface StateDeclaration { * }) * ``` */ - redirectTo?: ( string | - (($transition$: Transition) => TargetState) | - { state: (string|StateDeclaration), params: { [key: string]: any }} - ) + redirectTo?: RedirectToResult | Promise /** * A Transition Hook called with the state is being entered. See: [[IHookRegistry.onEnter]]