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 access protected field but private field inside nested class #59989

Open
jrieken opened this issue Sep 17, 2024 · 0 comments Β· May be fixed by #60001
Open

Cannot access protected field but private field inside nested class #59989

jrieken opened this issue Sep 17, 2024 · 0 comments Β· May be fixed by #60001
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Sep 17, 2024

πŸ”Ž Search Terms

private, protected

πŸ•— Version & Regression Information

Version 5.6.2

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBAYwDYEMDOa4DEITgbwChC5S4woIZgFqATOGACwEs0BJNABUutuAYBeOAEYA3CTIUWANxTVGrDtyiz5wOMPHEycAEYooACgCUALhx4iu3QggA7NPGbzNithJtlJXqMBgArlD2cPbAAO6IqBhwoNT2dJiWBDpeNmgQALb+rPYA5qYpacVwfoHBivIAdMxsnDxqCgDUlTA1SvW8NPSeJaQAvj42g7qD-UA

πŸ’» Code

export class Foo {

    protected thisIsProtected = 1;
    private thisIsPrivate = 1;

    bar():Foo {
        const that = this;
        
        return new class extends Foo {

            something() {
                return that.thisIsPrivate + that.thisIsProtected;
            }
        }
    }
}

πŸ™ Actual behavior

I get a compile error for that.thisIsProtected, but not for that.thisIsPrivate

πŸ™‚ Expected behavior

I can access the protected field, like the private

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Sep 17, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants