OLD | NEW |
1 import {CONST, CONST_EXPR, forwardRef} from 'angular2/src/facade/lang'; | |
2 | |
3 @CONST | |
4 export class MyClass { | 1 export class MyClass { |
5 private error: string = 'error'; | 2 private error: string = 'error'; |
6 constructor(private ctorField: string) {} | 3 constructor(private ctorField: string) {} |
7 | 4 |
8 get field(): string { | 5 get field(): string { |
9 // TODO: TypeScript doesn't parse the RHS as StringKeyword so we lose | 6 // TODO: TypeScript doesn't parse the RHS as StringKeyword so we lose |
10 // the translation of string -> String. | 7 // the translation of string -> String. |
11 // We use capital S String here, even though it wouldn't run in TS. | 8 // We use capital S String here, even though it wouldn't run in TS. |
12 if ((<any>' world') instanceof String) { | 9 if ((<any>' world') instanceof String) { |
13 return this.ctorField + ' world'; | 10 return this.ctorField + ' world'; |
14 } else { | 11 } else { |
15 return this.error; | 12 return this.error; |
16 } | 13 } |
17 } | 14 } |
18 | 15 |
19 namedParam({x = '?'}: any = {}) { return 'hello' + x; } | 16 namedParam({x = '?'}: any = {}) { return 'hello' + x; } |
20 } | 17 } |
21 | 18 |
22 interface Observer { | 19 interface Observer { |
23 update(o: Object, arg: Object); | 20 update(o: Object, arg: Object); |
24 } | 21 } |
25 | 22 |
26 export class MySubclass extends MyClass implements Observer { | 23 export class MySubclass extends MyClass implements Observer { |
27 constructor(ctorField: string) { super(ctorField); } | 24 constructor(ctorField: string) { super(ctorField); } |
28 get subclassField(): string { return this.field; } | 25 get subclassField(): string { return this.field; } |
29 update(o: Object, arg: Object) { this.field = arg.toString(); } | 26 update(o: Object, arg: Object) { this.field = arg.toString(); } |
30 } | 27 } |
31 | 28 |
32 export const SOME_ARRAY = CONST_EXPR([1, 2, 3]); | 29 export const SOME_ARRAY = [1, 2, 3]; |
33 export const someArray = forwardRef(() => SOME_ARRAY); | 30 export const someArray = SOME_ARRAY; |
OLD | NEW |