Skip to content

Commit

Permalink
fix(redirectTo): fix TS type signature of redirectTo
Browse files Browse the repository at this point in the history
relates to #3117
  • Loading branch information
christopherthielen committed Nov 2, 2016
1 parent 0948309 commit 2c059c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const noop = () => <any> undefined;

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

export interface Obj extends Object {
Expand Down
8 changes: 8 additions & 0 deletions src/params/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions src/state/interface.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -431,10 +440,7 @@ export interface StateDeclaration {
* })
* ```
*/
redirectTo?: ( string |
(($transition$: Transition) => TargetState) |
{ state: (string|StateDeclaration), params: { [key: string]: any }}
)
redirectTo?: RedirectToResult | Promise<RedirectToResult>

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

0 comments on commit 2c059c4

Please sign in to comment.