Open js-d-coder opened 1 year ago
Hey @js-d-coder ,
I faced with similar issue during upgrading to Node 18 and using "target": "es2022"
instead of es2021
in tsconfig. Switching back to es2021
helped me 🤷♂️
I'm seeing the same issue where exposeDefaultValues
is being ignored for plainToClass
.
It seems that, when used together with exposeUnsetFields:false
, exposeDefaultValues:false
does not work as expected.
I think this should be checked.
The same error is making test cases fail on https://github.com/typestack/class-transformer/issues/1505#issuecomment-2116699303. These should pass with the fix.
cc: @ahochsteger
Do we have any updates on this issue ?
Description
Please consider this code:
As you can notice IMDB class has a property
rating
with default value. Sometimes I want the instance object to not have default value if the property is missing and sometimes I do.To achieve this using
exposeDefaultValues: false
option if I don't want default value for the missing property.exposeDefaultValues: false
seems to not be working in above code snippet.Expected behavior
Default value should not be set to
rating
property i.e.rating
property should not have value of0
and should not be present inmovie1
object.Actual behavior
'rating
property has default value set in
movie1` object.