|
|
|
|
|
by bennettpompi1
20 days ago
|
|
I may be missing something, but your example doesn't typecheck? class Animal { }
class Dog extends Animal{
bark(){return 1}
}
class Cat extends Animal{
bark(){return 1}
}
const dogs: Dog[] = []
const animals: Animal[] = dogs
animals.push(new Cat())
animals[0].bark() <<<<< "Property 'bark' does not exist on type 'Animal'."
|
|