Skip to content

Commit 002e8d1

Browse files
refactor(common): simplify references to angular.* functions
refactor(*): for typescript 1.8: export all interfaces/classes/enums exposed externally refactor(*): for typescript 1.8: switch up /// <reference paths refactor(Router): rename to UIRouter to avoid same name as component Router refactor(*): Switch types from angular IPromise to ES6 Promise
1 parent b3bd2fe commit 002e8d1

30 files changed

+65
-75
lines changed

src/common/common.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
import {isFunction, isString, isArray, isRegExp, isDate} from "./predicates";
44
import { all, pattern, any, not, prop, curry, val } from "./hof";
55

6-
let angular = (<any> window).angular;
7-
export const fromJson = angular && angular.fromJson || _fromJson;
8-
export const toJson = angular && angular.toJson || _toJson;
9-
export const copy = angular && angular.copy || _copy;
10-
export const forEach = angular && angular.forEach || _forEach;
11-
export const extend = angular && angular.extend || _extend;
12-
export const equals = angular && angular.equals || _equals;
6+
let angular = (<any> window).angular || {};
7+
export const fromJson = angular.fromJson || _fromJson;
8+
export const toJson = angular.toJson || _toJson;
9+
export const copy = angular.copy || _copy;
10+
export const forEach = angular.forEach || _forEach;
11+
export const extend = angular.extend || _extend;
12+
export const equals = angular.equals || _equals;
1313
export const identity = (x) => x;
1414
export const noop = () => undefined;
1515

16-
type Mapper<X, T> = (x: X, key?: (string|number)) => T;
16+
export type Mapper<X, T> = (x: X, key?: (string|number)) => T;
1717
export interface TypedMap<T> { [key: string]: T; }
1818
export type Predicate<X> = (X) => boolean;
1919
export type IInjectable = (Function|any[]);
@@ -570,3 +570,9 @@ function _arraysEq(a1, a2) {
570570
if (a1.length !== a2.length) return false;
571571
return arrayTuples(a1, a2).reduce((b, t) => b && _equals(t[0], t[1]), true);
572572
}
573+
//
574+
//const _addToGroup = (result, keyFn) => (item) =>
575+
// (result[keyFn(item)] = result[keyFn(item)] || []).push(item) && result;
576+
//const groupBy = (array, keyFn) => array.reduce((memo, item) => _addToGroup(memo, keyFn), {});
577+
//
578+
//

src/common/coreservices.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let services: CoreServices = {
2727
["port", "protocol", "host", "baseHref", "html5Mode", "hashPrefix" ]
2828
.forEach(key => services.locationConfig[key] = notImplemented(key));
2929

30-
interface CoreServices {
30+
export interface CoreServices {
3131
$q; // : IQService;
3232
$injector; // : IInjectorService;
3333
/** Services related to getting or setting the browser location (url) */
@@ -37,7 +37,7 @@ interface CoreServices {
3737
template: TemplateServices;
3838
}
3939

40-
interface LocationServices {
40+
export interface LocationServices {
4141
replace(): void;
4242
url(newurl: string): string;
4343
url(): string;
@@ -47,7 +47,7 @@ interface LocationServices {
4747
onChange(callback: Function): Function;
4848
}
4949

50-
interface LocationConfig {
50+
export interface LocationConfig {
5151
port(): number;
5252
protocol(): string;
5353
host(): string;
@@ -58,7 +58,7 @@ interface LocationConfig {
5858
hashPrefix(newprefix: string): string;
5959
}
6060

61-
interface TemplateServices {
61+
export interface TemplateServices {
6262
get(url: string): string;
6363
}
6464

src/common/trace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ function stringify(o) {
4343
return JSON.stringify(o, (key, val) => format(val)).replace(/\\"/g, '"');
4444
}
4545

46-
enum Category {
46+
export enum Category {
4747
RESOLVE, TRANSITION, HOOK, INVOKE, UIVIEW, VIEWCONFIG
4848
}
4949

50-
class Trace {
50+
export class Trace {
5151
approximateDigests: number;
5252

5353
constructor() {

src/ng1.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference path='../typings/angularjs/angular.d.ts' />
2+
/// <reference path='../typings/es6-shim/es6-shim.d.ts' />
13
/**
24
* Main entry point for angular 1.x build
35
*/

src/ng1/services.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
* @preferred
1010
*/
1111

12-
/** for typedoc */
1312
/// <reference path='../../typings/angularjs/angular.d.ts' />
14-
import {Router} from "../router";
13+
/// <reference path='../../typings/es6-shim/es6-shim.d.ts' />
14+
15+
/** for typedoc */
16+
import {UIRouter} from "../router";
1517
import {services} from "../common/coreservices";
1618
import {map, bindFunctions, removeFrom, find, noop} from "../common/common";
1719
import {prop, propEq} from "../common/hof";
@@ -148,14 +150,14 @@ function runBlock($injector, $q) {
148150

149151
app.run(runBlock);
150152

151-
let router: Router = null;
153+
let router: UIRouter = null;
152154

153155
ng1UIRouter.$inject = ['$locationProvider'];
154156
/** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
155157
function ng1UIRouter($locationProvider) {
156158

157159
// Create a new instance of the Router when the ng1UIRouterProvider is initialized
158-
router = new Router();
160+
router = new UIRouter();
159161

160162
// Bind LocationConfig.hashPrefix to $locationProvider.hashPrefix
161163
bindFunctions($locationProvider, services.locationConfig, $locationProvider, ['hashPrefix']);

src/ng1/stateEvents.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919

2020
/** for typedoc */
21-
/// <reference path='../../typings/angularjs/angular.d.ts' />
22-
2321
import {IServiceProviderFactory} from "angular";
2422
import {StateService, StateProvider} from "../state/interface";
2523
import {TargetState} from "../state/module";

src/ng1/stateFilters.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/** @module state */ /** for typedoc */
2-
/// <reference path='../../typings/angularjs/angular.d.ts' />
32

43
/**
54
* @ngdoc filter

src/ng1/viewDirective.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
var ngMajorVer = angular.version.major;
22
var ngMinorVer = angular.version.minor;
33
/** @module view */ /** for typedoc */
4-
/// <reference path='../../typings/angularjs/angular.d.ts' />
5-
64
import {extend} from "../common/common";
75
import {isDefined} from "../common/predicates";
86
import {trace} from "../common/trace";

src/ng1/viewScroll.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/** @module view */ /** for typedoc */
2-
/// <reference path='../../typings/angularjs/angular.d.ts' />
32
import {IServiceProviderFactory} from "angular";
43

54
/**

src/params/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export interface ParamDeclaration {
214214
dynamic: boolean;
215215
}
216216

217-
interface Replace {
217+
export interface Replace {
218218
from: string;
219219
to: string;
220220
}

0 commit comments

Comments
 (0)