Closed pavankris closed 3 months ago
@pavankris hi!
Why shouldn't the value be passed in constructor ?
I think because class-transformer doesn't support such case. The reasons might be the follow:
Those two points should tell us, that to support such feature we need to change somehow interface of plainToInstance
function, in order to give it a info of how to get constructor parameters and how they should look like.
The issue does not contain a simple reproduction case.
Closing as invalid.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
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 argumentbut if we pass
newValue = new (targetType as any)(value);
everything worksExpected behavior
Why shouldn't the value be passed in constructor ?