Number Deserialization
Closed this issue · 1 comments
solenya-group commented
The class-transformer library converts NaN values to null values. This is documented, but it's not ideal. The work around is currently to use the attached
method on component as follows:
class MyComponent {
myNum = NaN
attached () {
this.myNum = this.myNum == null ? NaN : this.myNum
}
Potentially a better solution is given a numeric type annotation like this:
@Type (() => Number) myNum = NaN
That pickle would, upon deserialization, automatically convert the null to NaN.
solenya-group commented
Implemented & documented. Use the @num decorator:
class MyComponent {
@Num myNum = NaN
}