diff --git a/tests/baselines/reference/classConstructorAccessibility4.errors.txt b/tests/baselines/reference/classConstructorAccessibility4.errors.txt new file mode 100644 index 00000000000..1cc50e3f4c8 --- /dev/null +++ b/tests/baselines/reference/classConstructorAccessibility4.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts(16,9): error TS2673: Constructor of class 'A' is private and only accessible within the class declaration. +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts(33,9): error TS2674: Constructor of class 'D' is protected and only accessible within the class declaration. + + +==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts (2 errors) ==== + class A { + private constructor() { } + + method() { + class B { + method() { + new A(); // OK + } + } + + class C extends A { // OK + } + } + } + + var a = new A(); // error + ~~~~~~~ +!!! error TS2673: Constructor of class 'A' is private and only accessible within the class declaration. + + class D { + protected constructor() { } + + method() { + class E { + method() { + new D(); // OK + } + } + + class F extends D { // OK + } + } + } + + var d = new D(); // error + ~~~~~~~ +!!! error TS2674: Constructor of class 'D' is protected and only accessible within the class declaration. \ No newline at end of file diff --git a/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts b/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts new file mode 100644 index 00000000000..e75f9be6fde --- /dev/null +++ b/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts @@ -0,0 +1,33 @@ +class A { + private constructor() { } + + method() { + class B { + method() { + new A(); // OK + } + } + + class C extends A { // OK + } + } +} + +var a = new A(); // error + +class D { + protected constructor() { } + + method() { + class E { + method() { + new D(); // OK + } + } + + class F extends D { // OK + } + } +} + +var d = new D(); // error \ No newline at end of file