Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot use protected constructor of a parent's parent #12256

Copy link
Copy link
@westy92

Description

@westy92
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.