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.
This adds support for runtime types using deepkit and resolves #168. What makes this approach more useful is that it's a typescript first approach to writing types and we still get the developer happiness of what makes rails rails.
In ruby land, we often come across tools (things like graphql, typelizer, etc) that encourage
This flow always felt a bit off to me, for a few reasons:
Bottom line. These tools tries it best to ensure that the backend and frontend are "in-sync", but it fails to improve the rails experience while also making the typescript experience worse.
Contracts
There has to be a better alternative. Let's let rails be rails, but reinforce the shape and values through runtime contracts on reception (during dev) by your frontend instead of end-to-end typing. Without compromising the rails and typescript experience.
Runtime types
This PR brings in deepkit as an optional dependency. There are no changes to the way folks work already in Superglue. Just pass a type to useContent as you normally would
And you get runtime types for free:
Almost, free. We do have to add
and add another plugin to your build tool of choice, e.g. esbuild:
But the tradeoff seems good for such an amazing DX.
A nice side effect: You can use any json builder library with Superglue and still get this experience.