Skip to content

Svelte 5: Passing Date objects through $state.snapshot() turns it into a string #12561

Closed
@longnguyen2004

Description

@longnguyen2004

Describe the bug

When passing a state containing a Date object into $state.snapshot, it got turned into a string (more precisely an ISO 8601 date string, as if toISOString() is called on the Date object). The equivalent structuredClone function doesn't have the same issue.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACnWO0QqCQBBFf2UYelCQAvXJNIj6i-xh0ZEWbHfZGYsQ_z1WonzIxzn33sOM2OmeGIvLiEbdCQs8OocJysuFgx_UC2GCbAffBFJy47WTQ21q6UlAiAUq2LAooWgMuBZVgKEnnAOKA5ri_XKQfhdbNsrxzUoU-Nxa9DKoYFW5LOZQAYsfGhk8tafeGpqFWTCWu9_PZgx4q0AbFmUast3snD5Juh5l61H-J8IE77bVnaYWC_EDTdfpDUDRaelvAQAA

Logs

No response

System Info

`[email protected]` on the Svelte 5 REPL

Severity

blocking an upgrade

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions