Skip to content

fix: Expose's since and until do not work when using properties with a different name #1832

@gkasse

Description

@gkasse

Description

When converting objects with different names with properties using plainToInstance, version control using since/until does not work.

class Sample {
    @Expose({ name: 'fizz', since: 0, until: 1 })
    foo: any;
    @Expose({ name: 'buzz', since: 2 })
    bar: any;
}

const result = plainToInstance(Sample, { fizz: 'fizz', buzz: 'buzz' }, { version: 2 });
console.log(result);

dependencies:
class-transformer: 0.5.1
typescript: 4.9.5

Expected behavior

When the plainToInstance method is executed with version 2 specified, it is expected to ignore the object “fizz” and return an instance of Sample where foo is undefined.

Sample { bar: 'buzz' }

Actual behavior

Sample { foo: 'fizz', bar: 'buzz' }

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