type-fest
type-fest copied to clipboard
Type for serializable objects?
Would it make sense to create a type for serializable objects?
Similar to Jsonify et al., this would match values that could losslessly be deep-copied via structuredClone
or postMessage
.
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- The funding will be given to active contributors.
- Thank you in advance for helping prioritize & fund our backlog.
How would you use it?
For reference, the algorithm for structuredClone
: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
My two use cases are similar to how I currently use the Jsonify family of types:
- To ensure that an application state object as passed between a web worker and the main thread remains serializable
- To more strongly type the outputs of a structuredClone call
It's more like Jsonifiable
. Could maybe be called StructuredCloneable
.