I've tried to define a custom getter like this:
import { Expose } from 'class-transformer';
export class MyDTOResponse {
@Expose()
id: string;
@Expose()
name: string;
@Expose()
get thisIsATest(): string {
return 'yolo';
}
}
This is how I transform it:
plainToClass(MyDTOResponse, MyRawDataObject, {
excludeExtraneousValues: true,
});
As described in the documentation here: https://github.com/typestack/class-transformer#exposing-getters-and-method-return-values
However, the response is only:
{
"id": "f8c213c7-5853-4d01-b424-cb0349a6c580",
"name": "Clean the kitchen!"
}
I am not sure what I am doing wrong exactly, but I am missing the "thisIsATest" property.