telescope icon indicating copy to clipboard operation
telescope copied to clipboard

`Date` in `fromJSON` being parsed into Timestamp instead of Date

Open NoahSaso opened this issue 1 year ago • 0 comments

The fromJSON of /cosmos.base.tendermin.v1beta1.Header is generated with an error for the time key:

      time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
Type 'Timestamp | undefined' is not assignable to type 'Date | undefined'.
  Type 'Timestamp' is missing the following properties from type 'Date': toDateString, toTimeString, toLocaleDateString, toLocaleTimeString, and 37 more.ts(2322)
types.ts(51, 3): The expected type comes from property 'time' which is declared here on type 'Header'
(property) Header.time: Date

while to toJSON function is generated correctly:

    message.time !== undefined && (obj.time = message.time.toISOString());

Header's time field is a Date, but fromJSON seems to be outputting a Timestamp via fromJsonTimestamp instead of a Date. The JSON representation is the Date's ISO string.

NoahSaso avatar Aug 16 '23 09:08 NoahSaso