Not sure if this belongs in #start or #query, but type inference when using server functions
Hello, not sure where this belongs, but I'm using Start and Query and my type inference seems to be wrong when my objects contain dates. See images and code related.


16 Replies
metropolitan-bronzeOP•11mo ago
I forgot to mention that I am using superjson
like-gold•11mo ago
no, this one will not apply to server function
metropolitan-bronzeOP•11mo ago
is there a way to wrap it?
like-gold•11mo ago
I think there’s no way to do this rn
metropolitan-bronzeOP•11mo ago
Gotcha. What did you do to resolve your issue?
Or did you just wrap your dates with new Date(stringValue) to get the date object back?
like-gold•11mo ago
I didn’t resolve the issue
I just called the superjson api manually to test the result on client
I think we need to wait this PR first
like-gold•11mo ago
GitHub
Chained Server Fn Syntax, ServerFn Middleware by tannerlinsley · Pu...
Todo:
Remove any "search" param specific terms/functionality from the validations utilities (including types and adapters)
Publish new validation packages (without the router- ...
like-gold•11mo ago
before they support superjson
metropolitan-bronzeOP•11mo ago
Gotcha. I guess for now I can just do
like-gold•11mo ago
Yeah, return a normal json object is a good solution for now
like-gold•11mo ago
The new API will look like this
https://vxtwitter.com/tannerlinsley/status/1844500352655335522?s=46
Twitter
vxTwitter / fixvx
💖 492 🔁 22
Tanner Linsley (@tannerlinsley)
Type-safe Server Function Middleware and upgraded Server Functions have been achieved internally @Tan_Stack Start. Shipping to alpha (maybe beta) ASAP
like-gold•11mo ago
The input will also support zod schema or other validation libs
Just like tRPC
Oh, u transforming the string to date object on client code
I think u can transform the date to string on server
And transform the date string to date object on client
This way, the types and data will match
metropolitan-bronzeOP•11mo ago
something like that I guess?
like-gold•11mo ago
yeah
and, when using server function, you don’t need to wrap the data with json() api
just return the data like tRPC
the json() api is for api route
metropolitan-bronzeOP•11mo ago
oops, thought you did, thank you
I ended up using this:
so