Closed ptrxyz closed 1 year ago
Maybe this would be of any help? https://github.com/blitz-js/superjson
Thanks for your feedback, that's a very good point! I just published v4.0.0 which enforces stricter types on the service. I decided against using superjson or similar approaches for now. The new typings will hopefully help to guard devs from the issues you mentioned.
FYI: Support for superjson has been added in v6.0.0
Awesome! Thanks a bunch!
First, great library, just perfect for small projects! No overload, no clutter, straight to the point :)
However I find when you return
from your service things go wrong a bit: since we rely on
type MyService = typeof MyService
, IntelliSense and TS think you actually return a Date/Map/Set object. However JSON serialization breaks this.This is quite dangerous in my opinion since you can easily break you API without any hint from tsc/the IDE.
Is there a simple fix for it? Maybe we can simply have the types adjusted? However this would still make it so that Sets/Maps are empty when passed through JSON.stringify. Maybe we can use
devalue
or another library to handle it?