-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typegen for routes with a client loader but no server loader #12117
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"react-router": patch | ||
--- | ||
|
||
Fix typegen for routes with a client loader but no server loader |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,15 +66,12 @@ type _CreateLoaderData< | |
ClientLoaderHydrate extends boolean, | ||
HasHydrateFallback | ||
> = | ||
[HasHydrateFallback, ClientLoaderHydrate] extends [true, true] ? | ||
[HasHydrateFallback, ClientLoaderHydrate] extends [true, true] ? | ||
IsDefined<ClientLoaderData> extends true ? ClientLoaderData : | ||
undefined | ||
: | ||
[IsDefined<ClientLoaderData>, IsDefined<ServerLoaderData>] extends [true, true] ? ServerLoaderData | ClientLoaderData : | ||
IsDefined<ClientLoaderData> extends true ? | ||
ClientLoaderHydrate extends true ? ClientLoaderData : | ||
ClientLoaderData | undefined | ||
: | ||
IsDefined<ClientLoaderData> extends true ? ClientLoaderData : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a route has a client loader but no server loader, then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I understanding this right that the absence of a I don't think I ever realized that 😅 |
||
IsDefined<ServerLoaderData> extends true ? ServerLoaderData : | ||
undefined | ||
|
||
|
@@ -221,7 +218,7 @@ type __tests = [ | |
CreateLoaderData<{ | ||
clientLoader: () => { a: string; b: Date; c: () => boolean }; | ||
}>, | ||
undefined | { a: string; b: Date; c: () => boolean } | ||
{ a: string; b: Date; c: () => boolean } | ||
> | ||
>, | ||
Expect< | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops - this was just a miss when this warning got added - I noticed doing some testing yesterday that it prints unnecessarily because paramRoutes is always defined and it also doesn't actually log the routes it's referring to 🤦♂️