Replies: 5 comments 2 replies
-
|
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.
-
|
A failing test was submitted in this PR: #13092 |
Beta Was this translation helpful? Give feedback.
-
|
There's an example of a workaround for |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Fixed by #13092 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The
Serializabletype currently definesMaps andSets 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
Serializetype is similar, but serializes types that extendMaporSet, rather than types that areMaps orSets (see https://github.com/remix-run/react-router/blob/ab67e21/packages/react-router/lib/types/route-data.ts#L23-L24).ReadonlyMapandReadonlySetare separate types that do not extendMaporSet, but they are subsets ofMapandSetthat only define the non-mutating methods.Since
ReadonlyMapandReadonlySetaren'tMapandSetand do not extendMapandSet, they do not serialize correctly (as a type, that is). Since they are Typescript-only types (in that you can't create aReadonlyMaporReadonlySetobject), they should serialize exactly likeMapandSet.I propose that
Serializable,Serialize, and any other types as needed be updated to support serializingReadonlyMapandReadonlySetso that code such asuseLoaderDatawill keepReadonlyMapandReadonlySettypes.Beta Was this translation helpful? Give feedback.
All reactions