Say I have the following interface...
interface Person {
name: string;
age: number;
}
```ts
and I have a class that uses the interface like this...
```ts
abstract class GenericForm<T> {
abstract validators: { [P in keyof T]: [T[P], ValidatorFn?] };
}
class PersonForm extends GenericForm<Partial<Person>> {
readonly validators = {};
constructor(readonly model: Partial<Person>) {
// ...
}
}
is it possible to create a decorator that will modify the PersonForm class to look like this?
@someDecorator(Person)
class PersonForm extends GenericForm<Partial<Person>> {
readonly validators = {};
// "injected" by @someDecorator
readonly name = this.get("name") as FormControl; // assume this.get is valid here. I am doing stuff with angular forms and omitted the part where i extend FormGroup for brevity.
readonly age = this.get("age") as FormControl;
// end "injections"
constructor(readonly model: Partial<Person>) {
// ...
}
}