From f2481e384662052e3e2316220d0b195e49e384c1 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Sat, 22 Feb 2025 16:08:24 -0700 Subject: [PATCH 1/4] Add failing tests for ReadonlyMap and ReadonlySet --- packages/react-router/lib/types/route-data.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/react-router/lib/types/route-data.ts b/packages/react-router/lib/types/route-data.ts index 9dc2b6b4da..26318a444c 100644 --- a/packages/react-router/lib/types/route-data.ts +++ b/packages/react-router/lib/types/route-data.ts @@ -108,6 +108,25 @@ type __tests = [ > >, Expect { a: string } | Response>, { a: string }>>, + Expect< + Equal< + ServerDataFrom< + () => { + map: Map; + readonlyMap: ReadonlyMap; + } + >, + { map: Map; readonlyMap: ReadonlyMap } + > + >, + Expect< + Equal< + ServerDataFrom< + () => { set: Set; readonlySet: ReadonlySet } + >, + { set: Set; readonlySet: ReadonlySet } + > + >, // ClientDataFrom Expect, undefined>>, From aa9a74996cb604d62abc643f69dbd57f57fa3a48 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Sat, 22 Feb 2025 16:16:16 -0700 Subject: [PATCH 2/4] Add bjohn465 to contributors.yml This is me signing the Contributor License Agreement (CLA). --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index cfbb9400d8..5ad6440c45 100644 --- a/contributors.yml +++ b/contributors.yml @@ -47,6 +47,7 @@ - BDomzalski - bhbs - bilalk711 +- bjohn465 - bobziroll - bravo-kernel - Brendonovich From 05e2051609af19629bd707be6f8f8a20a63696a2 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Sun, 23 Feb 2025 08:46:37 -0700 Subject: [PATCH 3/4] Add ReadonlyMap and ReadonlySet to Serialize type --- packages/react-router/lib/types/route-data.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-router/lib/types/route-data.ts b/packages/react-router/lib/types/route-data.ts index 26318a444c..fae6eb1d5c 100644 --- a/packages/react-router/lib/types/route-data.ts +++ b/packages/react-router/lib/types/route-data.ts @@ -25,7 +25,9 @@ type Serialize = // Map & Set T extends Map ? Map, Serialize> : + T extends ReadonlyMap ? ReadonlyMap, Serialize> : T extends Set ? Set> : + T extends ReadonlySet ? ReadonlySet> : // Array T extends [] ? [] : From bc4c0a838433f5d208b970ce3f5c1e3ae43e89e8 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Sun, 23 Feb 2025 08:56:53 -0700 Subject: [PATCH 4/4] Add changeset --- .changeset/fresh-pugs-relax.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fresh-pugs-relax.md diff --git a/.changeset/fresh-pugs-relax.md b/.changeset/fresh-pugs-relax.md new file mode 100644 index 0000000000..2c98b6c1f6 --- /dev/null +++ b/.changeset/fresh-pugs-relax.md @@ -0,0 +1,5 @@ +--- +"react-router": patch +--- + +Maintain `ReadonlyMap` and `ReadonlySet` types in server response data.