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: Strengthen route typings #9366
Merged
Merged
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
56022e7
Add conditional type to RouteObject
GuptaSiddhant 4c331d0
Add contributor
GuptaSiddhant 093a5c0
Enhance children if index is falsy
GuptaSiddhant d3cdf1a
Throw error in createRoutesFromChildren + test
c7e50a1
Update error message
e0903d5
fix: Stengthen route typings top to bottom
brophdawg11 8b6d8ed
Add test+invariant for index/path combinations
brophdawg11 e4cc495
Remove duplicate check
brophdawg11 5f2a196
Add invariant for index/path to flattenRoutes
brophdawg11 7622a69
Make children checks consistent
brophdawg11 7b7090e
Allow index + path routes
brophdawg11 7cbacec
remove data router example changes
brophdawg11 070abd4
Remove createroutesFromChildren test
brophdawg11 ac23968
Fix error message
brophdawg11 6d72e41
List type props
brophdawg11 7bee9dc
add changeset
brophdawg11 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
- goldins | ||
- gowthamvbhat | ||
- GraxMonzo | ||
- GuptaSiddhant | ||
- haivuw | ||
- hernanif1 | ||
- hongji00 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,23 +6,40 @@ import type { | |
Router, | ||
StaticHandlerContext, | ||
To, | ||
AgnosticRouteObject, | ||
AgnosticRouteMatch, | ||
AgnosticIndexRouteObject, | ||
AgnosticLayoutRouteObject, | ||
AgnosticPathRouteObject, | ||
} from "@remix-run/router"; | ||
import type { Action as NavigationType } from "@remix-run/router"; | ||
|
||
// Create react-specific types from the agnostic types in @remix-run/router to | ||
// export from react-router | ||
export interface RouteObject extends AgnosticRouteObject { | ||
export type IndexRouteObject = Omit<AgnosticIndexRouteObject, "children"> & { | ||
children?: undefined; | ||
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. why |
||
element?: React.ReactNode | null; | ||
errorElement?: React.ReactNode | null; | ||
}; | ||
export type PathRouteObject = Omit<AgnosticPathRouteObject, "children"> & { | ||
children?: RouteObject[]; | ||
element?: React.ReactNode | null; | ||
errorElement?: React.ReactNode | null; | ||
} | ||
}; | ||
export type LayoutRouteObject = Omit<AgnosticLayoutRouteObject, "children"> & { | ||
children?: RouteObject[]; | ||
element?: React.ReactNode | null; | ||
errorElement?: React.ReactNode | null; | ||
}; | ||
|
||
export interface DataRouteObject extends RouteObject { | ||
export type RouteObject = | ||
| IndexRouteObject | ||
| PathRouteObject | ||
| LayoutRouteObject; | ||
|
||
export type DataRouteObject = RouteObject & { | ||
children?: DataRouteObject[]; | ||
id: string; | ||
} | ||
}; | ||
|
||
export interface RouteMatch< | ||
ParamKey extends string = string, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Got rid of the duplication here -
<Route>
props are now justRouteObject
equivalents that expectReactNode
children instead ofReactElement
children