Skip to content

Commit cb87fa0

Browse files
committed
chore(build): migrated di to TypeScript
1 parent 649e276 commit cb87fa0

File tree

22 files changed

+319
-333
lines changed

22 files changed

+319
-333
lines changed

modules/angular2/di.js renamed to modules/angular2/di.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ export * from './src/di/decorators';
1010
export {Injector} from './src/di/injector';
1111
export {Binding, ResolvedBinding, Dependency, bind} from './src/di/binding';
1212
export {Key, KeyRegistry} from './src/di/key';
13-
export {KeyMetadataError, NoBindingError, AbstractBindingError, AsyncBindingError, CyclicDependencyError,
14-
InstantiationError, InvalidBindingError, NoAnnotationError} from './src/di/exceptions';
13+
export {
14+
NoBindingError,
15+
AbstractBindingError,
16+
AsyncBindingError,
17+
CyclicDependencyError,
18+
InstantiationError,
19+
InvalidBindingError,
20+
NoAnnotationError
21+
} from './src/di/exceptions';
1522
export {OpaqueToken} from './src/di/opaque_token';
23+
24+
// HACK: workaround for Traceur behavior.
25+
// It expects all transpiled modules to contain this marker.
26+
// TODO: remove this when we no longer use traceur
27+
export var __esModule = true;

modules/angular2/src/change_detection/exceptions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {ProtoRecord} from './proto_record';
2+
import {BaseException} from "angular2/src/facade/lang";
23

3-
export class ExpressionChangedAfterItHasBeenChecked extends Error {
4+
export class ExpressionChangedAfterItHasBeenChecked extends BaseException {
45
message:string;
56

67
constructor(proto:ProtoRecord, change:any) {
@@ -14,7 +15,7 @@ export class ExpressionChangedAfterItHasBeenChecked extends Error {
1415
}
1516
}
1617

17-
export class ChangeDetectionError extends Error {
18+
export class ChangeDetectionError extends BaseException {
1819
message:string;
1920
originalException:any;
2021
location:string;

modules/angular2/src/change_detection/parser/lexer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Injectable} from 'angular2/src/di/annotations_impl';
22
import {List, ListWrapper, SetWrapper} from "angular2/src/facade/collection";
3-
import {int, NumberWrapper, StringJoiner, StringWrapper} from "angular2/src/facade/lang";
3+
import {int, NumberWrapper, StringJoiner, StringWrapper, BaseException} from "angular2/src/facade/lang";
44

55
export const TOKEN_TYPE_CHARACTER = 1;
66
export const TOKEN_TYPE_IDENTIFIER = 2;
@@ -176,7 +176,7 @@ export const $RBRACE = 125;
176176
const $NBSP = 160;
177177

178178

179-
export class ScannerError extends Error {
179+
export class ScannerError extends BaseException {
180180
message:string;
181181
constructor(message) {
182182
super();

modules/angular2/src/core/compiler/element_injector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ export class ElementInjector extends TreeNode {
966966
}
967967
}
968968

969-
class OutOfBoundsAccess extends Error {
969+
class OutOfBoundsAccess extends BaseException {
970970
message:string;
971971
constructor(index) {
972972
super();
@@ -978,7 +978,7 @@ class OutOfBoundsAccess extends Error {
978978
}
979979
}
980980

981-
class QueryError extends Error {
981+
class QueryError extends BaseException {
982982
message:string;
983983
// TODO(rado): pass the names of the active directives.
984984
constructor() {

modules/angular2/src/di/annotations.es6 renamed to modules/angular2/src/di/annotations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export {
1010
Optional as OptionalAnnotation,
1111
Injectable as InjectableAnnotation,
1212
DependencyAnnotation, // abstract base class, does not need a decorator
13-
} from './annotations_impl';
13+
} from './annotations_impl';

modules/angular2/src/di/annotations_impl.js renamed to modules/angular2/src/di/annotations_impl.ts

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import {CONST} from "angular2/src/facade/lang";
22

3+
// HACK: workaround for Traceur behavior.
4+
// It expects all transpiled modules to contain this marker.
5+
// TODO: remove this when we no longer use traceur
6+
export var __esModule = true;
7+
38
/**
49
* A parameter annotation that specifies a dependency.
510
*
@@ -11,12 +16,10 @@ import {CONST} from "angular2/src/facade/lang";
1116
*
1217
* @exportedAs angular2/di_annotations
1318
*/
19+
20+
@CONST()
1421
export class Inject {
15-
token;
16-
@CONST()
17-
constructor(token) {
18-
this.token = token;
19-
}
22+
constructor(public token) {}
2023
}
2124

2225
/**
@@ -32,12 +35,9 @@ export class Inject {
3235
*
3336
* @exportedAs angular2/di_annotations
3437
*/
38+
@CONST()
3539
export class InjectPromise {
36-
token;
37-
@CONST()
38-
constructor(token) {
39-
this.token = token;
40-
}
40+
constructor(public token) {}
4141
}
4242

4343
/**
@@ -53,17 +53,14 @@ export class InjectPromise {
5353
*
5454
* @exportedAs angular2/di_annotations
5555
*/
56+
@CONST()
5657
export class InjectLazy {
57-
token;
58-
@CONST()
59-
constructor(token) {
60-
this.token = token;
61-
}
58+
constructor(public token) {}
6259
}
6360

6461
/**
65-
* A parameter annotation that marks a dependency as optional. {@link Injector} provides `null` if the dependency is not
66-
* found.
62+
* A parameter annotation that marks a dependency as optional. {@link Injector} provides `null` if
63+
* the dependency is not found.
6764
*
6865
* ```
6966
* class AComponent {
@@ -75,16 +72,15 @@ export class InjectLazy {
7572
*
7673
* @exportedAs angular2/di_annotations
7774
*/
75+
@CONST()
7876
export class Optional {
79-
@CONST()
80-
constructor() {
81-
}
8277
}
8378

8479
/**
8580
* `DependencyAnnotation` is used by the framework to extend DI.
8681
*
87-
* Only annotations implementing `DependencyAnnotation` are added to the list of dependency properties.
82+
* Only annotations implementing `DependencyAnnotation` are added to the list of dependency
83+
* properties.
8884
*
8985
* For example:
9086
*
@@ -108,19 +104,14 @@ export class Optional {
108104
*
109105
* @exportedAs angular2/di_annotations
110106
*/
107+
@CONST()
111108
export class DependencyAnnotation {
112-
@CONST()
113-
constructor() {
114-
}
115-
116-
get token() {
117-
return null;
118-
}
109+
get token() { return null; }
119110
}
120111

121112
/**
122-
* A marker annotation that marks a class as available to `Injector` for creation. Used by tooling for
123-
* generating constructor stubs.
113+
* A marker annotation that marks a class as available to `Injector` for creation. Used by tooling
114+
* for generating constructor stubs.
124115
*
125116
* ```
126117
* class NeedsService {
@@ -132,8 +123,6 @@ export class DependencyAnnotation {
132123
* ```
133124
* @exportedAs angular2/di_annotations
134125
*/
126+
@CONST()
135127
export class Injectable {
136-
@CONST()
137-
constructor() {
138-
}
139128
}

0 commit comments

Comments
 (0)