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

Super class members forced to use public for subclass access #429

Closed
diverted247 opened this issue Aug 11, 2014 · 1 comment
Closed

Super class members forced to use public for subclass access #429

diverted247 opened this issue Aug 11, 2014 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@diverted247
Copy link

///ERROR - Test.foo is inaccessible

class Test{
    private foo:number = 123;
}
class SubTest extends Test{
    constructor(){
        super();
        this.foo = 456;

    }
}
var subTest = new SubTest();

VS:

///Forced to make Test.foo public to avoid compiler error

class Test{
    foo:number = 123;
}
class SubTest extends Test{
    constructor(){
        super();
        this.foo = 456;

    }
}
var subTest = new SubTest();

The above example will only work is the Test class member foo is made public. The key issue is that it discourages use of the Superclass directly given all member properties and methods must be public.

@diverted247 diverted247 changed the title Super class properties forced to use public for subclass access Super class members forced to use public for subclass access Aug 11, 2014
@DickvdBrink
Copy link
Contributor

I think what you want is protected, so #1?

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants