Microsoft/TypeScript

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

Open

#8.624 geöffnet am 16. Mai 2016

Auf GitHub ansehen
 (22 Kommentare) (1 Reaktion) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
Breaking ChangeEffort: ModerateHelp WantedSuggestion

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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)

Contributor Guide