class-transformer icon indicating copy to clipboard operation
class-transformer copied to clipboard

fix: Transform not working with "[email protected]"

Open andrazperson opened this issue 11 months ago • 0 comments

Description

When updating the "reflect-metadata" package from 0.2.1 to 0.2.2, the value transformation defined in @Transform decorator does not execute.

This is a class I have defined in the code, which works with the previous version of "reflect-metadata".

import { Transform } from "class-transformer";
import moment from "moment-timezone";

export class Event {
  id!: string;
  visible!: boolean;

  @Transform(({ value }: { value: string }) => moment.parseZone(value).toDate())
  start!: Date;

  @Transform(({ value }: { value: string }) => moment.parseZone(value).toDate())
  end!: Date;
}

Expected behavior

Event.start and Event.end should be of type Date, with the parsed timezone.

Actual behavior

Event.start and Event.end are not transformed string types.

andrazperson avatar Nov 10 '24 13:11 andrazperson