You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When running custom task with io.runTask the return value of the callback is piped through JSON.parse(JSON.stringify(value)). I understand that this is necessary to serialize the value for caching. In Typescript this is also reflected by doing JSON<T> with the return-type.
For me, this was cumbersome as I wanted to pass object with for example Dates and DX would fall apart.
Describe the solution you'd like to see
I created the following function to serialize the value with superjson. Superjson is similar to JSON.stringify and JSON.parse but allow for dates etc to survive.
For me and my team this function solves the Issue, but maybe there is way for this to end up directly in the @trigger.dev/sdk:
Is your feature request related to a problem? Please describe.
When running custom task with
io.runTask
the return value of the callback is piped throughJSON.parse(JSON.stringify(value))
. I understand that this is necessary to serialize the value for caching. In Typescript this is also reflected by doingJSON<T>
with the return-type.For me, this was cumbersome as I wanted to pass object with for example Dates and DX would fall apart.
Describe the solution you'd like to see
I created the following function to serialize the value with superjson. Superjson is similar to JSON.stringify and JSON.parse but allow for dates etc to survive.
For me and my team this function solves the Issue, but maybe there is way for this to end up directly in the
@trigger.dev/sdk
:Describe alternate solutions
Alternatively this little helper function could be hinted at in the docs.
Additional information
No response
The text was updated successfully, but these errors were encountered: