Closed
Description
TypeScript Version: 2.0.9
Code
class Base {
protected constructor() { }
public instance1 = new Base(); // allowed
}
class Subclass extends Base {
public instance1_1 = new Base(); // allowed
public instance1_2 = new Subclass(); // allowed
}
class SubclassOfSubclass extends Subclass {
public instance2_1 = new Base(); // error
public instance2_2 = new Subclass(); // error
public instance2_3 = new SubclassOfSubclass(); // error
}
Expected behavior:
Calling a protected constructor of a parent's parent is allowed.
Actual behavior:
test.ts(12,26): error TS2674: Constructor of class 'Base' is protected and only accessible within the class declaration.
test.ts(13,26): error TS2674: Constructor of class 'Base' is protected and only accessible within the class declaration.
test.ts(14,26): error TS2674: Constructor of class 'Base' is protected and only accessible within the class declaration.