Note: I am coming into this question (and typescript in general) from the prespective of NestJS.
This may not be the right place to ask this, but I've noticed how you must specify Expose() decorator when transforming with class-transformer with the option excludeExtranousValues set to true...
I read some more about this and what I understood is that without the decorator, when typescript is converted to javascript it loses the properties and so can't know which properties belong to the class hence why you need the decorator.
The thing is.. This is not correct... When creating a random class with typescript and transpiling it into javascript I can clearly see all the properties still intact in the javascript class, and if I run a short js script utilizing this class, for instance:
class Who {
prop1;
prop2;
}
const obj = new Who();
console.log(Object.keys(obj));
Javascript clearly knows which properties belong to the class...
So the question remains - why are decorators so important to know which properties belong to the class if it seems like we can know it without them as well..?