Microsoft/TypeScript

Bug: Accessing private statics in a class via its derived class is allowed

Open

#8624 aperta il 16 mag 2016

Vedi su GitHub
 (22 commenti) (1 reazione) (0 assegnatari)TypeScript (6726 fork)batch import
Breaking ChangeEffort: ModerateHelp WantedSuggestion

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

TypeScript Version:

1.8.X

Code

class FooBase {
    private static privateStatic: string = "";

    testBase(): void {
        console.log(FooBase.privateStatic);

        // Should error, but doesn't
        console.log(Foo.privateStatic);
   }
}

class Foo extends FooBase {
    test() {
        // Should error, and does
        console.log(Foo.privateStatic);
    }
}

Expected behavior: Accessing Foo.privateStatic shouldn't be allowed, regardless of the context it's called in.

Actual behavior: FooBase is allowed to do this.

(thanks @sethbrenith for deducing this)

Guida contributor