When exporting an assignment, dates are transformed to strings. Then, when importing back the assignment, using class-transformer to cast the plain javascript object to an instance of a class doesn't call its constructor. Therefore, the milestones are imported with its date as a string while a Date is expected. As a result, when calling a Date method, an error is thrown.
Steps to reproduce
Create a new assignment, with a repository
Load this assignment
Add a milestone
Export the assignment
Import back the assignment
Load the imported assignment
Actual result
When loading the assignment, the following error is thrown and the assignment is not loaded. Also, the whole application is frozen and a reload is required.
Expected result
The assignment is successfully loaded.
Hints
Make sure that class-transformer transforms the dates to the right format, using @Type(() => Date)
Description
When exporting an assignment, dates are transformed to strings. Then, when importing back the assignment, using class-transformer to cast the plain javascript object to an instance of a class doesn't call its constructor. Therefore, the milestones are imported with its date as a string while a
Date
is expected. As a result, when calling aDate
method, an error is thrown.Steps to reproduce
Actual result
When loading the assignment, the following error is thrown and the assignment is not loaded. Also, the whole application is frozen and a reload is required.
Expected result
The assignment is successfully loaded.
Hints
Make sure that class-transformer transforms the dates to the right format, using
@Type(() => Date)