kiliman / remix-typedjson

This package is a replacement for superjson to use in your Remix app. It handles a subset of types that `superjson` supports, but is faster and smaller.
MIT License
435 stars 19 forks source link

defer/<TypedAwait> - Date Type not converted back to Date #36

Open piotrkulpinski opened 9 months ago

piotrkulpinski commented 9 months ago

Hi,

I'm using the typeddefer function of the package and run into some bug where Date objects are not converted back to Date after using <TypedAwait />.

The VS Code says it's of type Date when in reality it's a string. This causes a lot of issues.

CleanShot 2023-11-16 at 09 08 39

You can find the basic example here: https://stackblitz.com/edit/remix-run-remix-v11hmg?file=app%2Froutes%2F_index.tsx

abustany commented 8 months ago

Same issue here, running Remix 2.3.1

abustany commented 8 months ago

OK I found the issue in my case: the Promise was nested inside the loader data. Looking at the code, it seems that typeddefer only looks at top level properties.

jagodin commented 7 months ago

I'm also running into this issue. Following the example in the README, it seems as though the data gets properly serialized by typeddefer but fails to properly deserialize somewhere in <TypedAwait />.

I can also see that when navigating back to the deferred route, the previously resolved data is correctly deserialized for a brief moment before the loader runs again. Notice the flicker of typeof slowData.tomorrow is object in the video:

https://github.com/kiliman/remix-typedjson/assets/17988743/842728c8-0427-4fd7-aa6b-3380fed681d4

hunkydoris commented 6 months ago

@kiliman , if you have time, could you please take a look at it? I'm using the latest Remix (2.6.0), and this issue still persists. As @abustany mentioned earlier, it causes an issue when a date is nested inside an array. Also when we refresh the browser.