Skip to content

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

Open
@andrazperson

Description

@andrazperson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triageIssues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions