Skip to content

Commit b19b5fa

Browse files
committed
fix: add inject array to StateDefaultSepcifier type.
1 parent 8b15899 commit b19b5fa

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import angular = require("angular");
22

33
declare module 'angular' {
44
export namespace ui {
5-
export type DefaultSpecifier = string | (() => string) | (() => ng.IPromise<string>);
5+
export type StateDefaultSpecifier = string
6+
| ((...args: any[]) => string)
7+
| ((...args: any[]) => ng.IPromise<string>)
8+
| (string | ((...args: any[]) => string))[]
9+
| (string | ((...args: any[]) => ng.IPromise<string>))[];
610
interface IState {
7-
default?: DefaultSpecifier
11+
default?: StateDefaultSpecifier
812
}
913
}
1014
}

src/angular-ui-router-default.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ angular.module(moduleName, ['ui.router'])
7575
}
7676

7777
function invokeAbstract(state: ng.ui.IState) {
78-
var defaultState: ng.ui.DefaultSpecifier;
78+
var defaultState: ng.ui.StateDefaultSpecifier;
7979

8080
if (state.default) {
8181
defaultState = state.default;
8282
} else {
8383
defaultState = state.abstract as any;
8484
}
8585

86-
if (!angular.isString(defaultState)) {
87-
return $q.when($injector.invoke(defaultState));
86+
if (defaultState instanceof Function || defaultState instanceof Array) {
87+
return $q.when($injector.invoke(defaultState as any));
8888
} else {
8989
return $q.when(defaultState);
9090
}

0 commit comments

Comments
 (0)