-
Notifications
You must be signed in to change notification settings - Fork 90
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
Skipping transformation #283
Comments
Hi @luixo! Can you elaborate on why you’re looking to cut out those superfluous fields in If you still want to omit those bytes afterwards, you could traverse the object before passing it to SuperJSON and I try to keep SuperJSON light on config, so I‘m always recommending user-land solutions first. Let me know if that works for you! |
It's mostly DX.
That would be great, actually. |
I get that feeling :D But I promise you, if you neatly tuck it away into its own little function, it will spark a little more joy, and the function will feel a sense of purpose in its life. Jokes aside - I get it, but this is a matter of complexity on SuperJSON's end, and i'd like to keep that as low as possible.
Going off the current implementation, it looks like custom-registered transformers are taking precedence over built-in transformers for So this should work, yes! If you end up using this, please send a pull request with a test for this, so we can make sure there's no regressions to it.
Try it out and let us know what you found! |
I investigated the source code and found no way to omit transforming a non-deep object (which is not a plain object, array, map, set or registered class). Or should I do deep omitting of undefined values myself before feeding the object to superjson? |
Hello,
I'm using
superjson
in my project (withtRPC
) and there is a bunch of fields which are optional - hence emitting undefined in a server response going client-side.It resolves to emptiness in
json
field, but a bunch ofundefined
s inmeta
which I don't actually need as I don't go through object props anywhere in my project.Can I turn off this transformation somehow? Can I
register
an override over this type? If so - how can I make it be omitted?The text was updated successfully, but these errors were encountered: