I want to create a class type for classes with certain properties. E.g.:
class Cat {
name = 'cat';
}
class Dog {
name = 'dog';
}
type Animal = ???;
function foo(AnimalClass: Animal) {
console.log((new AnimalClass()).name);
}
I want doSomething to accept any class that has a string name property. The only way I could do this is:
class _Animal {
name: string;
}
type Animal = typeof _Animal;
Is there a way to do this without defining a new JS class? I just want the type.