TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
8.11k stars 630 forks source link

Type safety breaks around Dates and other non standard objects when using server functions #2693

Open AlexGaudon opened 2 hours ago

AlexGaudon commented 2 hours ago

Which project does this relate to?

Start

Describe the bug

Start Server Functions don't respect TanStack Router specified transformers.

See pictures below:

SuperJSON is specified Image

Function returns a Date, with the proper type Image

Loader gets the incorrect type (the actual value is just a stringified date) Image

Your Example Website or App

https://github.com/AlexGaudon/start-date-repro

Steps to Reproduce the Bug or Issue

  1. Clone the repo
  2. Run bun install
  3. Run bun --bun run dev
  4. Navigate to http://localhost:3000 and observe the error

Expected behavior

As a user, I expect server functions to automatically conform to the transformer specified.

Screenshots or Videos

No response

Platform

Additional context

No response

aretrace commented 2 hours ago

I think a future test suite with various serializers (e.g., Rich-Harris/devalue) would be a good idea.

SeanCassiere commented 2 hours ago

This should be getting addressed in the server functions PR.

AlexGaudon commented 2 hours ago

Just for clarity, are you talking about https://github.com/TanStack/router/pull/2513