From b19b5fa28bf1f1ed4b6adea1a2c744795cc8768d Mon Sep 17 00:00:00 2001 From: Stepan Riha Date: Tue, 11 Oct 2016 17:01:26 -0500 Subject: [PATCH] fix: add inject array to StateDefaultSepcifier type. --- index.d.ts | 8 ++++++-- src/angular-ui-router-default.ts | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4a742b4..8ebb386 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,9 +2,13 @@ import angular = require("angular"); declare module 'angular' { export namespace ui { - export type DefaultSpecifier = string | (() => string) | (() => ng.IPromise); + export type StateDefaultSpecifier = string + | ((...args: any[]) => string) + | ((...args: any[]) => ng.IPromise) + | (string | ((...args: any[]) => string))[] + | (string | ((...args: any[]) => ng.IPromise))[]; interface IState { - default?: DefaultSpecifier + default?: StateDefaultSpecifier } } } diff --git a/src/angular-ui-router-default.ts b/src/angular-ui-router-default.ts index f4310bc..f96c764 100644 --- a/src/angular-ui-router-default.ts +++ b/src/angular-ui-router-default.ts @@ -75,7 +75,7 @@ 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; @@ -83,8 +83,8 @@ angular.module(moduleName, ['ui.router']) 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); }