Replies: 2 comments
-
Here's a repository with an example: https://github.com/bjohn465/readonly-example Currently, TypeScript throws an error on line 61 and line 67 because the |
Beta Was this translation helpful? Give feedback.
0 replies
-
A failing test was submitted in this PR: #13092 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
Serializable
type currently definesMap
s andSet
s as serializable if their keys and/or values are serializable (see https://github.com/remix-run/react-router/blob/ab67e21/packages/react-router/lib/server-runtime/single-fetch.ts#L298-L299).The
Serialize
type is similar, but serializes types that extendMap
orSet
, rather than types that areMap
s orSet
s (see https://github.com/remix-run/react-router/blob/ab67e21/packages/react-router/lib/types/route-data.ts#L23-L24).ReadonlyMap
andReadonlySet
are separate types that do not extendMap
orSet
, but they are subsets ofMap
andSet
that only define the non-mutating methods.Since
ReadonlyMap
andReadonlySet
aren'tMap
andSet
and do not extendMap
andSet
, they do not serialize correctly (as a type, that is). Since they are Typescript-only types (in that you can't create aReadonlyMap
orReadonlySet
object), they should serialize exactly likeMap
andSet
.I propose that
Serializable
,Serialize
, and any other types as needed be updated to support serializingReadonlyMap
andReadonlySet
so that code such asuseLoaderData
will keepReadonlyMap
andReadonlySet
types.Beta Was this translation helpful? Give feedback.
All reactions