29 lines
No EOL
776 B
Text
29 lines
No EOL
776 B
Text
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts (2 errors) ====
|
|
class C {
|
|
public constructor(public x: number) { }
|
|
}
|
|
|
|
class D {
|
|
private constructor(public x: number) { } // error
|
|
~~~~~~~
|
|
!!! 'private' modifier cannot appear on a constructor declaration.
|
|
}
|
|
|
|
var c = new C(1);
|
|
var d = new D(1);
|
|
|
|
module Generic {
|
|
class C<T> {
|
|
public constructor(public x: T) { }
|
|
}
|
|
|
|
class D<T> {
|
|
private constructor(public x: T) { } // error
|
|
~~~~~~~
|
|
!!! 'private' modifier cannot appear on a constructor declaration.
|
|
}
|
|
|
|
var c = new C(1);
|
|
var d = new D(1);
|
|
}
|
|
|