123 lines
2.1 KiB
Text
123 lines
2.1 KiB
Text
=== tests/cases/compiler/declarationEmit_protectedMembers.ts ===
|
|
|
|
// Class with protected members
|
|
class C1 {
|
|
>C1 : C1
|
|
|
|
protected x: number;
|
|
>x : number
|
|
|
|
protected f() {
|
|
>f : () => number
|
|
|
|
return this.x;
|
|
>this.x : number
|
|
>this : C1
|
|
>x : number
|
|
}
|
|
|
|
protected set accessor(a: number) { }
|
|
>accessor : number
|
|
>a : number
|
|
|
|
protected get accessor() { return 0; }
|
|
>accessor : number
|
|
>0 : number
|
|
|
|
protected static sx: number;
|
|
>sx : number
|
|
|
|
protected static sf() {
|
|
>sf : () => number
|
|
|
|
return this.sx;
|
|
>this.sx : number
|
|
>this : typeof C1
|
|
>sx : number
|
|
}
|
|
|
|
protected static set staticSetter(a: number) { }
|
|
>staticSetter : number
|
|
>a : number
|
|
|
|
protected static get staticGetter() { return 0; }
|
|
>staticGetter : number
|
|
>0 : number
|
|
}
|
|
|
|
// Derived class overriding protected members
|
|
class C2 extends C1 {
|
|
>C2 : C2
|
|
>C1 : C1
|
|
|
|
protected f() {
|
|
>f : () => number
|
|
|
|
return super.f() + this.x;
|
|
>super.f() + this.x : number
|
|
>super.f() : number
|
|
>super.f : () => number
|
|
>super : C1
|
|
>f : () => number
|
|
>this.x : number
|
|
>this : C2
|
|
>x : number
|
|
}
|
|
protected static sf() {
|
|
>sf : () => number
|
|
|
|
return super.sf() + this.sx;
|
|
>super.sf() + this.sx : number
|
|
>super.sf() : number
|
|
>super.sf : () => number
|
|
>super : typeof C1
|
|
>sf : () => number
|
|
>this.sx : number
|
|
>this : typeof C2
|
|
>sx : number
|
|
}
|
|
}
|
|
|
|
// Derived class making protected members public
|
|
class C3 extends C2 {
|
|
>C3 : C3
|
|
>C2 : C2
|
|
|
|
x: number;
|
|
>x : number
|
|
|
|
static sx: number;
|
|
>sx : number
|
|
|
|
f() {
|
|
>f : () => number
|
|
|
|
return super.f();
|
|
>super.f() : number
|
|
>super.f : () => number
|
|
>super : C2
|
|
>f : () => number
|
|
}
|
|
static sf() {
|
|
>sf : () => number
|
|
|
|
return super.sf();
|
|
>super.sf() : number
|
|
>super.sf : () => number
|
|
>super : typeof C2
|
|
>sf : () => number
|
|
}
|
|
|
|
static get staticGetter() { return 1; }
|
|
>staticGetter : number
|
|
>1 : number
|
|
}
|
|
|
|
// Protected properties in constructors
|
|
class C4 {
|
|
>C4 : C4
|
|
|
|
constructor(protected a: number, protected b) { }
|
|
>a : number
|
|
>b : any
|
|
}
|