Skip to content

Commit 30124bd

Browse files
fix(typescript): Remove angular1 specific types from ui-router-core methods
Fixes #2693
1 parent 8c0344f commit 30124bd

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/justjs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ services.$injector = {
7272
let STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
7373
let ARGUMENT_NAMES = /([^\s,]+)/g;
7474
if (!isInjectable(fn)) throw new Error(`Not an injectable function: ${fn}`);
75-
if (fn && fn.$inject) return fn.$inject;
75+
if (fn && fn['$inject']) return fn['$inject'];
7676
if (isArray(fn)) return (fn as any).slice(0, -1);
7777
let fnStr = fn.toString().replace(STRIP_COMMENTS, '');
7878
let result = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);

src/state/state.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {isObject} from "../common/predicates";
33
import {bindFunctions} from "../common/common";
44
import {BuilderFunction} from "./stateBuilder";
55
import {StateRegistry} from "./stateRegistry";
6-
import {State} from "./stateObject";
7-
import {Ng1StateDeclaration} from "../ng1/interface"; // TS4053
6+
import {StateDeclaration} from "./interface";
7+
import {State} from "./stateObject"; // has or is using
88

99
/**
1010
* @ngdoc object
@@ -262,8 +262,8 @@ export class StateProvider {
262262
* To create a parent/child state use a dot, e.g. "about.sales", "home.newest".
263263
* @param {object} definition State configuration object.
264264
*/
265-
state(name: string, definition: Ng1StateDeclaration): StateProvider;
266-
state(definition: Ng1StateDeclaration): StateProvider;
265+
state(name: string, definition: StateDeclaration): StateProvider;
266+
state(definition: StateDeclaration): StateProvider;
267267
state(name: any, definition?: any) {
268268
if (isObject(name)) {
269269
definition = name;

src/state/stateBuilder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function resolvablesBuilder(state: State): Resolvable[] {
138138

139139
/** fetch DI annotations from a function or ng1-style array */
140140
const annotate = (fn: Function) =>
141-
fn.$inject || services.$injector.annotate(fn, services.$injector.strictDi);
141+
fn['$inject'] || services.$injector.annotate(fn, services.$injector.strictDi);
142142

143143
/** true if the object has both `token` and `resolveFn`, and is probably a [[ResolveLiteral]] */
144144
const isResolveLiteral = (obj: any) => !!(obj.token && obj.resolveFn);

src/url/urlRouter.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import {extend, bindFunctions, IInjectable} from "../common/common";
33
import {isFunction, isString, isDefined, isArray} from "../common/predicates";
44
import {UrlMatcher} from "./urlMatcher";
5-
import {services, $InjectorLike} from "../common/coreservices";
5+
import {services, $InjectorLike, LocationServices} from "../common/coreservices";
66
import {UrlMatcherFactory} from "./urlMatcherFactory";
77
import {StateParams} from "../params/stateParams";
8-
import IInjectorService = angular.auto.IInjectorService;
98
import {RawParams} from "../params/interface";
10-
import ILocationService = angular.ILocationService;
119

1210
/** @hidden */
1311
let $location = services.location;
@@ -75,7 +73,7 @@ export class UrlRouterProvider {
7573
/** @hidden */
7674
rules: Function[] = [];
7775
/** @hidden */
78-
otherwiseFn: ($injector: IInjectorService, $location: ILocationService) => string;
76+
otherwiseFn: ($injector: $InjectorLike, $location: LocationServices) => string;
7977
/** @hidden */
8078
interceptDeferred = false;
8179

@@ -121,7 +119,7 @@ export class UrlRouterProvider {
121119
*
122120
* @return [[$urlRouterProvider]] (`this`)
123121
*/
124-
rule(rule: ($injector: IInjectorService, $location: ILocationService) => string): UrlRouterProvider {
122+
rule(rule: ($injector: $InjectorLike, $location: LocationServices) => string): UrlRouterProvider {
125123
if (!isFunction(rule)) throw new Error("'rule' must be a function");
126124
this.rules.push(rule);
127125
return this;
@@ -154,7 +152,7 @@ export class UrlRouterProvider {
154152
*
155153
* @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
156154
*/
157-
otherwise(rule: string | (($injector: IInjectorService, $location: ILocationService) => string)): UrlRouterProvider {
155+
otherwise(rule: string | (($injector: $InjectorLike, $location: LocationServices) => string)): UrlRouterProvider {
158156
if (!isFunction(rule) && !isString(rule)) throw new Error("'rule' must be a string or function");
159157
this.otherwiseFn = isString(rule) ? () => rule : rule;
160158
return this;

0 commit comments

Comments
 (0)