Map returns undefined values with never versions

Author: driescroonsCreated Jun 28, 2022Updated Mar 3, 2026
Labelstype: fixstatus: needs triage

I've got the following code that I set up for testing purposes:

@Exclude()
class Transformer {
  @Expose()
  @IsString({ each: true })
  public map!: Map<string, string>;
}

const obj = {
  map: new Map([
    ["1", "123"],
    ["2", "123"],
    ["3", "123"]
  ])
};

let data = plainToClass(Transformer, obj);
console.log(data);

Ever since 0.4.1, the values of the map return undefined (after moving to plainToInstance).

The following printscreen is the result of using version 0.4.1: image

The following printscreen is the result of using0.4.0: image

As you can see, the values are not undefined.

Did the syntax of validating a map change? Or is there something wrong? Following link is the CSB for testing: https://codesandbox.io/s/busy-kilby-7e8z73?file=/src/index.ts

Source: typestack/class-transformer