OLD | NEW |
1 export class MyClass { | 1 export class MyClass { |
2 private error: string = 'error'; | 2 private error: string = 'error'; |
3 constructor(private ctorField: string) {} | 3 constructor(private ctorField: string) {} |
4 | 4 |
5 get field(): string { | 5 get field(): string { |
6 // 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 |
7 // the translation of string -> String. | 7 // the translation of string -> String. |
8 // 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. |
9 if ((<any>' world') instanceof String) { | 9 if ((<any>' world') instanceof String) { |
10 return this.ctorField + ' world'; | 10 return this.ctorField + ' world'; |
11 } else { | 11 } else { |
12 return this.error; | 12 return this.error; |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 namedParam({x = '?'}: any = {}) { return 'hello' + x; } | 16 namedParam({x = '?'}: any = {}) { |
| 17 return 'hello' + x; |
| 18 } |
17 } | 19 } |
18 | 20 |
19 interface Observer { | 21 interface Observer { |
20 update(o: Object, arg: Object); | 22 update(o: Object, arg: Object); |
21 } | 23 } |
22 | 24 |
23 export class MySubclass extends MyClass implements Observer { | 25 export class MySubclass extends MyClass implements Observer { |
24 constructor(ctorField: string) { super(ctorField); } | 26 constructor(ctorField: string) { |
25 get subclassField(): string { return this.field; } | 27 super(ctorField); |
26 update(o: Object, arg: Object) { this.field = arg.toString(); } | 28 } |
| 29 get subclassField(): string { |
| 30 return this.field; |
| 31 } |
| 32 update(o: Object, arg: Object) { |
| 33 this.field = arg.toString(); |
| 34 } |
27 } | 35 } |
28 | 36 |
29 export const SOME_ARRAY = [1, 2, 3]; | 37 export const SOME_ARRAY = [1, 2, 3]; |
30 export const someArray = SOME_ARRAY; | 38 export const someArray = SOME_ARRAY; |
OLD | NEW |