I worked with decorators in Typescript, and I have a simple problem, suppose I have my own decorator called RetainTypeand a class like this:
class Person {
@RetainType name: string;
@RetainType age: number;
@RetainType dateOfBirth: Date;
}
I would like to write:
@RetainType class Person {
name: string;
age: number;
dateOfBirth: Date;
}
In other words, is there a way to apply a decorator to all the properties of a class? I use @RetainTypeto extract metadata about individual properties (design: type specific). It would be nice to have a more concise way to do this than annotate all the fields one by one.
source
share