Typescript: DateTime properties are mapped to Date objects but they should be string
As the title says, the typescript interface generator maps the date/datetime/time types to Typescript's Date object (https://github.com/api-platform/client-generator/blob/master/src/generators/TypescriptInterfaceGenerator.js#L47).
However, API Platform by default serializes DateTime objects as ISO 8601 strings, so we should change the type to string I think, otherwise we will run into all sorts of typescript errors when trying to use the date string (which the TS compiler would see as a Date object).
I could do a PR with the change from Date to string, however I have another question: Can the user change how PHP DateTimeInterface is serialized by Api Platform (i.e. from string to timestamp)? If so, how could we tell this to the client generator?
There should be a "denormalization" phase in the browser where this date should be transformed from a string to a Date instance imo.
I'd say it makes sense if we assume that the interfaces do not represent Api Platform resources but rather how the frontend app denormalizes them.
At the moment, I was using these interfaces to type hint the JSON objects received from the Api Platform backend, if we were to assume this denormalization phase is necessary we would not be able to type hint the responses without having wrong types for date fields, correct?
Personally, I'd prefer having both objects typed, but this means that the generated interfaces should represent how Api Platform serializes (i.e. DateTime is mapped to a string), and then the frontend can declare its own "denormalized" interfaces.
I was surprised to find out the JSON date strings are typed as Date, since that never actually happens. Why does API platform assume a conversion?