I am trying to detect a specific Class type using TypeScript. Seems like it should be a straight forward task but I haven't found any straight forward documentation on how to do this. Here is a simple use case example:
Class Car {}
Class Ford extends Car {}
Class Audi extends Car {}
let mustang = new Ford();
let a6 = new Audi();
// With an instance of Ford and Audi, how can I generically detect the type??
console.log(a6.getType()); // <--- this would return Audi
console.log(mustang.getType()); // <--- this would return Ford
I am trying to understand if there is any easy way to detect the most specific version of Car (in this case Audi or Ford). I understand that "getType()" is not a real function, but was interested to know if there is any easy way to achieve this, or a different way of thinking about this