-
Notifications
You must be signed in to change notification settings - Fork 519
Open
Labels
type: fixIssues describing a broken feature.Issues describing a broken feature.
Description
I have a DTO class and I want some specific key to be covert with different name only in instanceToPlain operation
the dto class:
export class CreateEventDto {
@Expose({ toClassOnly: true, name: 'type' })
eventTypeId: number;
}I can get it to work in plainToInstance
for example:
const obj = { type: 2 };
console.log(plainToInstance(CreateEventDto, obj)); // log CreateEventDto { eventTypeId: 2 }but if I convert it again using instanceToPlain, the result is showing { type: 2 } instead of { eventTypeId: 2 }
const obj = { type: 2 };
const dto = plainToInstance(CreateEventDto, obj);
console.log(dto); // log CreateEventDto { eventTypeId: 2 }
console.log(instanceToPlain(dto)); // log { type: 2 }, but I expect it to be { eventTypeId: 2 }Is there anything I'm doing wrong? or any proper way to this kind of conversion?
Thanks for answering :)
alexeychikkbobgubko and jfeliciani
Metadata
Metadata
Assignees
Labels
type: fixIssues describing a broken feature.Issues describing a broken feature.