That would be the sound way to do things, but it's also surprisingly common for arrays for some reason. It also doesn't get checked compile time in Java, although it does throw an exception because the arrays are type-enforced at runtime at least.
This compiles fine:
class A {}
class B1 extends A {}
class B2 extends A {}
public class MyClass {
public static void main(String args[]) {
A[] array = new B1[1];
array[0] = new B2();
}
}
That's because it's structurally typed (as opposed to nominally typed). I don't happen to prefer it, but I don't think it's fair to conflate that with unsoundness like the example given above; it's totally possible to have a sound structural type system. TypeScript doesn't happen to be sound, but it's not because of that.
This compiles fine: