You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* @flow */classAnimal{}classDogextendsAnimal{bark(){}}classCatextendsAnimal{meow(){}}constarr1=[newDog(),newDog()];constarr2: Animal[]=arr1;arr2.push(newCat());// arr1 == [new Dog(), new Dog(), new Cat()]arr1.forEach(c=>c.bark());//will fail at runtime with 'c.bark is not a function'
Expected behavior
Any sort of static checking error.
Actual behavior
JS runtime error: c.bark is not a function
Adding explicit type annotation to arr1 leads to type error (expected behavior).