After attempting to create a custom getter as shown below:
import { Expose } from 'class-transformer';
export class MyDTOResponse {
@Expose()
id: string;
@Expose()
name: string;
@Expose()
get thisIsATest(): string {
return 'yolo';
}
}
This is the process I follow for transformation:
plainToClass(MyDTOResponse, MyRawDataObject, {
excludeExtraneousValues: true,
});
Referencing the documentation at https://github.com/typestack/class-transformer#exposing-getters-and-method-return-values, my resulting response only contains:
{
"id": "f8c213c7-5853-4d01-b424-cb0349a6c580",
"name": "Clean the kitchen!"
}
I am unsure of the mistake I made, but the "thisIsATest" property seems to be missing.