7 ms·
I may be missing something, but your example doesn't typecheck? class Animal { } class Dog extends Animal{ bark(){return 1} } class Cat extends Ani
by bennettpompi1 2mo 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'."
- anematode 2mo agoShould be `dogs[0].bark()`