Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancies in Typescript declarations #1032

Closed
user72356 opened this issue Nov 14, 2022 · 3 comments
Closed

Discrepancies in Typescript declarations #1032

user72356 opened this issue Nov 14, 2022 · 3 comments
Assignees

Comments

@user72356
Copy link

user72356 commented Nov 14, 2022

I found what I believe are some discrepancies in the Typescript declaration file (replicache.d.ts).

  • The cookie property in the PullRequest type in file replicache.d.ts (lines 238) should be Cookie | null since this value is expected to be null for the first pull (according to the docs and further discussions on Discord).

  • The JSONValue and ReadonlyJSONValue types in replicache.d.ts (lines 2 and 12) should also accept Date 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.

@arv arv self-assigned this Nov 15, 2022
@arv
Copy link
Contributor

arv commented Nov 15, 2022

  • 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.

@arv arv closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2022
@user72356
Copy link
Author

user72356 commented Nov 16, 2022

  • PullRequest should not really parameterized. That was an internal implementation detail that leaked. cookie should always be ReadonlyJSONValue which already includes null.

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 use JSON.stringify or toJSON any more.

That's fair, but how do you suggest working with dates? Should I manually (de)serialize them within my own code?

@arv
Copy link
Contributor

arv commented Nov 16, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants