Closed user72356 closed 1 year ago
PullRequest
should not really parameterized. That was an internal implementation detail that leaked. cookie
should always be ReadonlyJSONValue
which already includes null
.
We do not want to support Date
. These are things that are JSON as specified on https://json.org. We only want things that round trip. We do not actually use JSON.stringify
or toJSON
any more.
PullRequest
should not really parameterized. That was an internal implementation detail that leaked.cookie
should always beReadonlyJSONValue
which already includesnull
.
I don't understand this. I'm working with TS in strict mode and I'm not allowing the any
type. If PullRequest
is an implementation detail that was leaked, how am I to use req.body
? By recreating my own type from the documentation?
- We do not want to support
Date
. These are things that are JSON as specified on https://json.org. We only want things that round trip. We do not actually useJSON.stringify
ortoJSON
any more.
That's fair, but how do you suggest working with dates? Should I manually (de)serialize them within my own code?
PullRequest is not an implementation detail. The thing that was a mistake to "leak" was the type parameter. cookie should always be ReadonlyJSONValue. This has been fixed for the next release. Sorry for the confusion.
I found what I believe are some discrepancies in the Typescript declaration file (replicache.d.ts).
The
cookie
property in thePullRequest
type in filereplicache.d.ts
(lines 238) should beCookie | null
since this value is expected to be null for the first pull (according to the docs and further discussions on Discord).The
JSONValue
andReadonlyJSONValue
types inreplicache.d.ts
(lines 2 and 12) should also acceptDate
objects since they are JSON serializable. I've tested it myself by just ignoring the ts warning about having a Data object in my pull response, and the data got serialized perfectly well.