Skip to content

Commit

Permalink
fix: add inject array to StateDefaultSepcifier type.
Browse files Browse the repository at this point in the history
  • Loading branch information
nonplus committed Oct 11, 2016
1 parent 8b15899 commit b19b5fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import angular = require("angular");

declare module 'angular' {
export namespace ui {
export type DefaultSpecifier = string | (() => string) | (() => ng.IPromise<string>);
export type StateDefaultSpecifier = string
| ((...args: any[]) => string)
| ((...args: any[]) => ng.IPromise<string>)
| (string | ((...args: any[]) => string))[]
| (string | ((...args: any[]) => ng.IPromise<string>))[];
interface IState {
default?: DefaultSpecifier
default?: StateDefaultSpecifier
}
}
}
6 changes: 3 additions & 3 deletions src/angular-ui-router-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ angular.module(moduleName, ['ui.router'])
}

function invokeAbstract(state: ng.ui.IState) {
var defaultState: ng.ui.DefaultSpecifier;
var defaultState: ng.ui.StateDefaultSpecifier;

if (state.default) {
defaultState = state.default;
} else {
defaultState = state.abstract as any;
}

if (!angular.isString(defaultState)) {
return $q.when($injector.invoke(defaultState));
if (defaultState instanceof Function || defaultState instanceof Array) {
return $q.when($injector.invoke(defaultState as any));
} else {
return $q.when(defaultState);
}
Expand Down

0 comments on commit b19b5fa

Please sign in to comment.