You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node version: 8.10
Npm version: 5.8.0
OS and version: MacOS 10.13.3
typed-rest-client version: stable
Issue Description
When using a type for the response which has Date as type for a field, that field ends up being a string, thus violating the type.
Expected behaviour
If I have a field which is a Date, I expect the deserialization to fail whenever the returned type isn't a date, or if the type does represent a parseable Date, that the field gets correctly transformed into a Date.
Actual behaviour
Instead of a Date, we get string. This means that any code that I write expecting there to be a Date, becomes type-unsafe as all the Date methods are not available in string objects.
Steps to reproduce
Create type class with Date field.
Make request to endpoint which returns a string-encoded standard JSON Date for that field.
Verify that none of the Date methods are available in the deserialized object.
As I understand, this may be tricky to solve as JSON.parse will see a string and leave it as a string. However, we could possibly introspect the type of the response and handle the Date manually.
The text was updated successfully, but these errors were encountered:
Environment
Node version: 8.10
Npm version: 5.8.0
OS and version: MacOS 10.13.3
typed-rest-client version: stable
Issue Description
When using a type for the response which has Date as type for a field, that field ends up being a string, thus violating the type.
Expected behaviour
If I have a field which is a Date, I expect the deserialization to fail whenever the returned type isn't a date, or if the type does represent a parseable Date, that the field gets correctly transformed into a Date.
Actual behaviour
Instead of a Date, we get string. This means that any code that I write expecting there to be a Date, becomes type-unsafe as all the Date methods are not available in string objects.
Steps to reproduce
As I understand, this may be tricky to solve as
JSON.parse
will see a string and leave it as a string. However, we could possibly introspect the type of the response and handle the Date manually.The text was updated successfully, but these errors were encountered: