1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
=== tests/cases/compiler/classMemberInitializerWithLamdaScoping.ts ===
declare var console: {
>console : { log(msg?: any): void; }
log(msg?: any): void;
>log : (msg?: any) => void
>msg : any
};
class Test {
>Test : Test
constructor(private field: string) {
>field : string
}
messageHandler = () => {
>messageHandler : () => void
>() => { var field = this.field; console.log(field); // Using field here shouldnt be error } : () => void
var field = this.field;
>field : string
>this.field : string
>this : this
>field : string
console.log(field); // Using field here shouldnt be error
>console.log(field) : void
>console.log : (msg?: any) => void
>console : { log(msg?: any): void; }
>log : (msg?: any) => void
>field : string
};
static field: number;
>field : number
static staticMessageHandler = () => {
>staticMessageHandler : () => void
>() => { var field = Test.field; console.log(field); // Using field here shouldnt be error } : () => void
var field = Test.field;
>field : number
>Test.field : number
>Test : typeof Test
>field : number
console.log(field); // Using field here shouldnt be error
>console.log(field) : void
>console.log : (msg?: any) => void
>console : { log(msg?: any): void; }
>log : (msg?: any) => void
>field : number
};
}
var field1: string;
>field1 : string
class Test1 {
>Test1 : Test1
constructor(private field1: string) {
>field1 : string
}
messageHandler = () => {
>messageHandler : () => void
>() => { console.log(field1); // But this should be error as the field1 will resolve to var field1 // but since this code would be generated inside constructor, in generated js // it would resolve to private field1 and thats not what user intended here. } : () => void
console.log(field1); // But this should be error as the field1 will resolve to var field1
>console.log(field1) : void
>console.log : (msg?: any) => void
>console : { log(msg?: any): void; }
>log : (msg?: any) => void
>field1 : any
// but since this code would be generated inside constructor, in generated js
// it would resolve to private field1 and thats not what user intended here.
};
static staticMessageHandler = () => {
>staticMessageHandler : () => void
>() => { console.log(field1); // This shouldnt be error as its a static property } : () => void
console.log(field1); // This shouldnt be error as its a static property
>console.log(field1) : void
>console.log : (msg?: any) => void
>console : { log(msg?: any): void; }
>log : (msg?: any) => void
>field1 : string
};
}
|