Skip to content

fix: Transform fails if the constructor expects an argument #1385

@pavankris

Description

@pavankris

Description

https://github.com/typestack/class-transformer/blob/develop/src/TransformOperationExecutor.ts#L160
TargetType is DecimalJS https://github.com/MikeMcl/decimal.js/blob/master/decimal.js#L4285
and the valueType is Decimal
None of the if block in TransformOperationExecutor.ts covers this as a result it falls into
newValue = new (targetType as any)();
and the default constructor expects a valid argument

but if we pass
newValue = new (targetType as any)(value);
everything works

Expected behavior

Why shouldn't the value be passed in constructor ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidIssues with no action to taketype: 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