TypeScript Class Decorators Causing advanced patterns in Inheritance Hierarchy
I'm confused about I'm deploying to production and I've been researching this but I'm trying to configure I'm working with a perplexing scenario with class decorators in TypeScript that seems to break the expected behavior of my inheritance hierarchy... I've defined a base class `Animal` and a derived class `Dog`. The `Animal` class has a decorator that adds a `species` property. However, when I instantiate the `Dog` class, I find that the `species` property is not being correctly inherited and ends up being `undefined`. Here's the relevant code: ```typescript function AddSpecies(species: string) { return function (constructor: Function) { constructor.prototype.species = species; }; } @AddSpecies('Mammal') class Animal { species: string; constructor() { console.log(`Animal created with species: ${this.species}`); } } class Dog extends Animal { constructor() { super(); console.log(`Dog created with species: ${this.species}`); } } const myDog = new Dog(); ``` When I run this code, I get the following output: ``` Animal created with species: undefined Dog created with species: undefined ``` I expected `species` to be `Mammal` for both the `Animal` and `Dog` instances. I've tried moving the decorator above the `Dog` class as well, but it doesn't seem to resolve the scenario. Could this be related to the execution context of decorators or the order of property initialization? Any insights on how to resolve this would be appreciated! This is part of a larger CLI tool I'm building. Am I approaching this the right way? I'm working with Typescript in a Docker container on Windows 10. Thanks for your help in advance!