Closed
Description
I recently learned that TypeScript classes inherit static methods and fields, which really surprised me! Unlike object instances, static properties aren't set in a constructor, so their static initialization can't be re-run for subclasses. As a result, inherited static fields in subclasses will take on the current value of their parents' field as their initial value, which can be surprising.
class A {
static bar: string = "foo";
}
A.bar = "Gotcha";
class B extends A {
}
console.log(B.bar); // prints 'Gotcha'
Is this desired behavior?