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
|
=== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts ===
class C {
>C : C
public constructor(public x: number) { }
>x : number
}
class D {
>D : D
private constructor(public x: number) { }
>x : number
}
class E {
>E : E
protected constructor(public x: number) { }
>x : number
}
var c = new C(1);
>c : C
>new C(1) : C
>C : typeof C
>1 : 1
var d = new D(1); // error
>d : any
>new D(1) : any
>D : typeof D
>1 : 1
var e = new E(1); // error
>e : any
>new E(1) : any
>E : typeof E
>1 : 1
module Generic {
>Generic : typeof Generic
class C<T> {
>C : C<T>
public constructor(public x: T) { }
>x : T
}
class D<T> {
>D : D<T>
private constructor(public x: T) { }
>x : T
}
class E<T> {
>E : E<T>
protected constructor(public x: T) { }
>x : T
}
var c = new C(1);
>c : C<number>
>new C(1) : C<number>
>C : typeof C
>1 : 1
var d = new D(1); // error
>d : any
>new D(1) : any
>D : typeof D
>1 : 1
var e = new E(1); // error
>e : any
>new E(1) : any
>E : typeof E
>1 : 1
}
|