Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
westy92 opened this issue Nov 15, 2016 · 0 comments
Closed

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

westy92 opened this issue Nov 15, 2016 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@westy92
Copy link

westy92 commented Nov 15, 2016

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.

@mhegazy mhegazy added the Bug A bug in TypeScript label Nov 15, 2016
@mhegazy mhegazy added this to the TypeScript 2.2 milestone Nov 15, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Dec 8, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants