hyperweb-io / hyperweb-io/telescope

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

Open
#446 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
154
Forks
53
PR merge metrics
No merged PRs in 30d

Description

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

```ts
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:

```ts
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.