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
Hey team! I think I found a bug with how the Await component handles serialization.
Here’s what’s happening:
If I pass a Date object directly from the loader, everything works fine — it’s recognized as a real Date.
But if I return a Date from a promise (e.g., via Await), the value looks like a Date in TypeScript, but it is a string at runtime.
You can reproduce it with this minimal example:
import{Await,createFileRoute}from"@tanstack/react-router";import{createServerFn}from"@tanstack/react-start";import{Suspense}from"react";constgetDate=createServerFn({method: "GET"}).handler(async()=>{awaitnewPromise((resolve)=>setTimeout(resolve,1000));returnnewDate();});exportconstRoute=createFileRoute("/_authed/(home)/")({loader: async()=>{return{date: newDate(),// This stays a DatedatePromise: getDate(),// This gets turned into a string};},component: Dashboard,});functionDashboard(){const{ date, datePromise }=Route.useLoaderData();console.log("DATE",typeofdate);// Logs "object" (correct)return(<Suspensefallback={<div>Loading...</div>}><Awaitpromise={datePromise}>{(date)=>{console.log("DATE2",typeofdate);// Logs "string", even though TS says Datereturn<div>{date}</div>;}}</Await></Suspense>);}
Let me know if I’m missing something.
Thanks!
Expected behavior
I believe it should be a date inside the Await component. (Or the TypeScript type should be a string)
Platform
OS: macOS
Browser: Chrome
Version: 1.114.27 (start)
The text was updated successfully, but these errors were encountered:
Which project does this relate to?
Start
Describe the bug
Hey team! I think I found a bug with how the Await component handles serialization.
Here’s what’s happening:
You can reproduce it with this minimal example:
Let me know if I’m missing something.
Thanks!
Expected behavior
I believe it should be a date inside the Await component. (Or the TypeScript type should be a string)
Platform
The text was updated successfully, but these errors were encountered: