Repository navigation
feat: automatically serialize JSON to equivalent type - #3261
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
sachinraja
approved these changes
Nov 25, 2022
sachinraja
left a comment
Member
There was a problem hiding this comment.
good for now, jump to definition works
Comment on lines
+41
to
+43
| type SerializeObject<T extends object> = { | ||
| [k in keyof T]: T[k] extends NonJsonPrimitive ? never : Serialize<T[k]>; | ||
| }; |
Member
There was a problem hiding this comment.
right now any keys of type NonJsonPrimitive show up as never because when I tried applying the filter keys strategy, TS broke
KATT
enabled auto-merge (squash)
November 25, 2022 17:33
KATT
disabled auto-merge
November 25, 2022 17:33
This was referenced Nov 25, 2022
|
This is an amazing quality of life improvement! Thank you ❤️🥳 |
1 task
KATT
added a commit
that referenced
this pull request
Nov 26, 2022
Co-authored-by: Sachin Raja <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1694
🎯 Changes
This PR adds support to automatically serialize the output as the JSON-representation of the same object.
It's currently usingUsing what Remix doestype-festas a dependency, which should probably be changed@trpc/clientor@trpc/react-querycalls will happen over the HTTP-boundary and that the response will be JSON. This is a fair assumption right now but if/when we add for instance an "SSR-link" you'll get unexpected resultstrpc/packages/tests/server/jsonify.test.ts
Lines 15 to 25 in 74f2767
trpc/packages/tests/server/jsonify.test.ts
Lines 35 to 47 in 74f2767
✅ Checklist
type-festsomehow