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
|
=== tests/cases/conformance/classes/members/privateNames/privateNameComputedPropertyName3.ts ===
class Foo {
>Foo : Foo
#name;
>#name : any
constructor(name) {
>name : any
this.#name = name;
>this.#name = name : any
>this.#name : any
>this : this
>name : any
}
getValue(x) {
>getValue : (x: any) => any
>x : any
const obj = this;
>obj : this
>this : this
class Bar {
>Bar : Bar
#y = 100;
>#y : number
>100 : 100
[obj.#name]() {
>[obj.#name] : () => any
>obj.#name : any
>obj : this
return x + this.#y;
>x + this.#y : any
>x : any
>this.#y : number
>this : this
}
}
return new Bar()[obj.#name]();
>new Bar()[obj.#name]() : error
>new Bar()[obj.#name] : error
>new Bar() : Bar
>Bar : typeof Bar
>obj.#name : any
>obj : this
}
}
console.log(new Foo("NAME").getValue(100));
>console.log(new Foo("NAME").getValue(100)) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>new Foo("NAME").getValue(100) : error
>new Foo("NAME").getValue : (x: any) => any
>new Foo("NAME") : Foo
>Foo : typeof Foo
>"NAME" : "NAME"
>getValue : (x: any) => any
>100 : 100
|