Skip to content

Commit

Permalink
fix(typescript): Remove angular1 specific types from ui-router-core m…
Browse files Browse the repository at this point in the history
…ethods

Fixes #2693
  • Loading branch information
christopherthielen committed Aug 11, 2016
1 parent 8c0344f commit 30124bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/justjs.ts
Expand Up @@ -72,7 +72,7 @@ services.$injector = {
let STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
let ARGUMENT_NAMES = /([^\s,]+)/g;
if (!isInjectable(fn)) throw new Error(`Not an injectable function: ${fn}`);
if (fn && fn.$inject) return fn.$inject;
if (fn && fn['$inject']) return fn['$inject'];
if (isArray(fn)) return (fn as any).slice(0, -1);
let fnStr = fn.toString().replace(STRIP_COMMENTS, '');
let result = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
Expand Down
8 changes: 4 additions & 4 deletions src/state/state.ts
Expand Up @@ -3,8 +3,8 @@ import {isObject} from "../common/predicates";
import {bindFunctions} from "../common/common";
import {BuilderFunction} from "./stateBuilder";
import {StateRegistry} from "./stateRegistry";
import {State} from "./stateObject";
import {Ng1StateDeclaration} from "../ng1/interface"; // TS4053
import {StateDeclaration} from "./interface";
import {State} from "./stateObject"; // has or is using

/**
* @ngdoc object
Expand Down Expand Up @@ -262,8 +262,8 @@ export class StateProvider {
* To create a parent/child state use a dot, e.g. "about.sales", "home.newest".
* @param {object} definition State configuration object.
*/
state(name: string, definition: Ng1StateDeclaration): StateProvider;
state(definition: Ng1StateDeclaration): StateProvider;
state(name: string, definition: StateDeclaration): StateProvider;
state(definition: StateDeclaration): StateProvider;
state(name: any, definition?: any) {
if (isObject(name)) {
definition = name;
Expand Down
2 changes: 1 addition & 1 deletion src/state/stateBuilder.ts
Expand Up @@ -138,7 +138,7 @@ export function resolvablesBuilder(state: State): Resolvable[] {

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

/** true if the object has both `token` and `resolveFn`, and is probably a [[ResolveLiteral]] */
const isResolveLiteral = (obj: any) => !!(obj.token && obj.resolveFn);
Expand Down
10 changes: 4 additions & 6 deletions src/url/urlRouter.ts
Expand Up @@ -2,12 +2,10 @@
import {extend, bindFunctions, IInjectable} from "../common/common";
import {isFunction, isString, isDefined, isArray} from "../common/predicates";
import {UrlMatcher} from "./urlMatcher";
import {services, $InjectorLike} from "../common/coreservices";
import {services, $InjectorLike, LocationServices} from "../common/coreservices";
import {UrlMatcherFactory} from "./urlMatcherFactory";
import {StateParams} from "../params/stateParams";
import IInjectorService = angular.auto.IInjectorService;
import {RawParams} from "../params/interface";
import ILocationService = angular.ILocationService;

/** @hidden */
let $location = services.location;
Expand Down Expand Up @@ -75,7 +73,7 @@ export class UrlRouterProvider {
/** @hidden */
rules: Function[] = [];
/** @hidden */
otherwiseFn: ($injector: IInjectorService, $location: ILocationService) => string;
otherwiseFn: ($injector: $InjectorLike, $location: LocationServices) => string;
/** @hidden */
interceptDeferred = false;

Expand Down Expand Up @@ -121,7 +119,7 @@ export class UrlRouterProvider {
*
* @return [[$urlRouterProvider]] (`this`)
*/
rule(rule: ($injector: IInjectorService, $location: ILocationService) => string): UrlRouterProvider {
rule(rule: ($injector: $InjectorLike, $location: LocationServices) => string): UrlRouterProvider {
if (!isFunction(rule)) throw new Error("'rule' must be a function");
this.rules.push(rule);
return this;
Expand Down Expand Up @@ -154,7 +152,7 @@ export class UrlRouterProvider {
*
* @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
*/
otherwise(rule: string | (($injector: IInjectorService, $location: ILocationService) => string)): UrlRouterProvider {
otherwise(rule: string | (($injector: $InjectorLike, $location: LocationServices) => string)): UrlRouterProvider {
if (!isFunction(rule) && !isString(rule)) throw new Error("'rule' must be a string or function");
this.otherwiseFn = isString(rule) ? () => rule : rule;
return this;
Expand Down

0 comments on commit 30124bd

Please sign in to comment.