Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions e2e/react-router/basic-file-based/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { Route as groupLayoutRouteImport } from './routes/(group)/_layout'
import { Route as anotherGroupOnlyrouteinsideRouteImport } from './routes/(another-group)/onlyrouteinside'
import { Route as RelativeUseNavigateRouteRouteImport } from './routes/relative/useNavigate/route'
import { Route as RelativeLinkRouteRouteImport } from './routes/relative/link/route'
import { Route as ParamsPsNonNestedRouteRouteImport } from './routes/params-ps/non-nested/route'
import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index'
import { Route as ParamsPsWildcardIndexRouteImport } from './routes/params-ps/wildcard/index'
import { Route as ParamsPsNamedIndexRouteImport } from './routes/params-ps/named/index'
Expand All @@ -61,13 +62,15 @@ import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layo
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'
import { Route as groupSubfolderInsideRouteImport } from './routes/(group)/subfolder/inside'
import { Route as groupLayoutInsidelayoutRouteImport } from './routes/(group)/_layout.insidelayout'
import { Route as ParamsPsNonNestedFooRouteRouteImport } from './routes/params-ps/non-nested/$foo_/route'
import { Route as ParamsPsNamedFooRouteRouteImport } from './routes/params-ps/named/$foo/route'
import { Route as RelativeUseNavigateWithSearchIndexRouteImport } from './routes/relative/useNavigate/with-search/index'
import { Route as RelativeUseNavigatePathIndexRouteImport } from './routes/relative/useNavigate/path/index'
import { Route as RelativeUseNavigateNestedIndexRouteImport } from './routes/relative/useNavigate/nested/index'
import { Route as RelativeLinkWithSearchIndexRouteImport } from './routes/relative/link/with-search/index'
import { Route as RelativeLinkPathIndexRouteImport } from './routes/relative/link/path/index'
import { Route as RelativeLinkNestedIndexRouteImport } from './routes/relative/link/nested/index'
import { Route as ParamsPsNonNestedFooBarRouteImport } from './routes/params-ps/non-nested/$foo_/$bar'
import { Route as ParamsPsNamedFooBarRouteRouteImport } from './routes/params-ps/named/$foo/$bar.route'
import { Route as RelativeUseNavigatePathPathIndexRouteImport } from './routes/relative/useNavigate/path/$path/index'
import { Route as RelativeUseNavigateNestedDeepIndexRouteImport } from './routes/relative/useNavigate/nested/deep/index'
Expand Down Expand Up @@ -219,6 +222,11 @@ const RelativeLinkRouteRoute = RelativeLinkRouteRouteImport.update({
path: '/relative/link',
getParentRoute: () => rootRouteImport,
} as any)
const ParamsPsNonNestedRouteRoute = ParamsPsNonNestedRouteRouteImport.update({
id: '/params-ps/non-nested',
path: '/params-ps/non-nested',
getParentRoute: () => rootRouteImport,
} as any)
const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({
id: '/',
path: '/',
Expand Down Expand Up @@ -343,6 +351,12 @@ const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({
path: '/insidelayout',
getParentRoute: () => groupLayoutRoute,
} as any)
const ParamsPsNonNestedFooRouteRoute =
ParamsPsNonNestedFooRouteRouteImport.update({
id: '/$foo_',
path: '/$foo',
getParentRoute: () => ParamsPsNonNestedRouteRoute,
} as any)
const ParamsPsNamedFooRouteRoute = ParamsPsNamedFooRouteRouteImport.update({
id: '/params-ps/named/$foo',
path: '/params-ps/named/$foo',
Expand Down Expand Up @@ -382,6 +396,11 @@ const RelativeLinkNestedIndexRoute = RelativeLinkNestedIndexRouteImport.update({
path: '/nested/',
getParentRoute: () => RelativeLinkRouteRoute,
} as any)
const ParamsPsNonNestedFooBarRoute = ParamsPsNonNestedFooBarRouteImport.update({
id: '/$bar',
path: '/$bar',
getParentRoute: () => ParamsPsNonNestedFooRouteRoute,
} as any)
const ParamsPsNamedFooBarRouteRoute =
ParamsPsNamedFooBarRouteRouteImport.update({
id: '/$bar',
Expand Down Expand Up @@ -429,6 +448,7 @@ export interface FileRoutesByFullPath {
'/posts': typeof PostsRouteWithChildren
'/remountDeps': typeof RemountDepsRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren
'/relative/link': typeof RelativeLinkRouteRouteWithChildren
'/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
Expand All @@ -444,6 +464,7 @@ export interface FileRoutesByFullPath {
'/relative': typeof RelativeIndexRoute
'/search-params/': typeof SearchParamsIndexRoute
'/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren
'/params-ps/non-nested/$foo': typeof ParamsPsNonNestedFooRouteRouteWithChildren
'/insidelayout': typeof groupLayoutInsidelayoutRoute
'/subfolder/inside': typeof groupSubfolderInsideRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
Expand All @@ -468,6 +489,7 @@ export interface FileRoutesByFullPath {
'/params-ps/wildcard': typeof ParamsPsWildcardIndexRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
'/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren
'/params-ps/non-nested/$foo/$bar': typeof ParamsPsNonNestedFooBarRoute
'/relative/link/nested': typeof RelativeLinkNestedIndexRoute
'/relative/link/path': typeof RelativeLinkPathIndexRoute
'/relative/link/with-search': typeof RelativeLinkWithSearchIndexRoute
Expand All @@ -489,6 +511,7 @@ export interface FileRoutesByTo {
'/notRemountDeps': typeof NotRemountDepsRoute
'/remountDeps': typeof RemountDepsRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren
'/relative/link': typeof RelativeLinkRouteRouteWithChildren
'/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
Expand All @@ -503,6 +526,7 @@ export interface FileRoutesByTo {
'/relative': typeof RelativeIndexRoute
'/search-params': typeof SearchParamsIndexRoute
'/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren
'/params-ps/non-nested/$foo': typeof ParamsPsNonNestedFooRouteRouteWithChildren
'/insidelayout': typeof groupLayoutInsidelayoutRoute
'/subfolder/inside': typeof groupSubfolderInsideRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
Expand All @@ -527,6 +551,7 @@ export interface FileRoutesByTo {
'/params-ps/wildcard': typeof ParamsPsWildcardIndexRoute
'/redirect/$target': typeof RedirectTargetIndexRoute
'/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren
'/params-ps/non-nested/$foo/$bar': typeof ParamsPsNonNestedFooBarRoute
'/relative/link/nested': typeof RelativeLinkNestedIndexRoute
'/relative/link/path': typeof RelativeLinkPathIndexRoute
'/relative/link/with-search': typeof RelativeLinkWithSearchIndexRoute
Expand All @@ -552,6 +577,7 @@ export interface FileRoutesById {
'/posts': typeof PostsRouteWithChildren
'/remountDeps': typeof RemountDepsRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren
'/relative/link': typeof RelativeLinkRouteRouteWithChildren
'/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/(another-group)/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
Expand All @@ -570,6 +596,7 @@ export interface FileRoutesById {
'/relative/': typeof RelativeIndexRoute
'/search-params/': typeof SearchParamsIndexRoute
'/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren
'/params-ps/non-nested/$foo_': typeof ParamsPsNonNestedFooRouteRouteWithChildren
'/(group)/_layout/insidelayout': typeof groupLayoutInsidelayoutRoute
'/(group)/subfolder/inside': typeof groupSubfolderInsideRoute
'/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute
Expand All @@ -594,6 +621,7 @@ export interface FileRoutesById {
'/params-ps/wildcard/': typeof ParamsPsWildcardIndexRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
'/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren
'/params-ps/non-nested/$foo_/$bar': typeof ParamsPsNonNestedFooBarRoute
'/relative/link/nested/': typeof RelativeLinkNestedIndexRoute
'/relative/link/path/': typeof RelativeLinkPathIndexRoute
'/relative/link/with-search/': typeof RelativeLinkWithSearchIndexRoute
Expand All @@ -619,6 +647,7 @@ export interface FileRouteTypes {
| '/posts'
| '/remountDeps'
| '/대한민국'
| '/params-ps/non-nested'
| '/relative/link'
| '/relative/useNavigate'
| '/onlyrouteinside'
Expand All @@ -634,6 +663,7 @@ export interface FileRouteTypes {
| '/relative'
| '/search-params/'
| '/params-ps/named/$foo'
| '/params-ps/non-nested/$foo'
| '/insidelayout'
| '/subfolder/inside'
| '/layout-a'
Expand All @@ -658,6 +688,7 @@ export interface FileRouteTypes {
| '/params-ps/wildcard'
| '/redirect/$target/'
| '/params-ps/named/$foo/$bar'
| '/params-ps/non-nested/$foo/$bar'
| '/relative/link/nested'
| '/relative/link/path'
| '/relative/link/with-search'
Expand All @@ -679,6 +710,7 @@ export interface FileRouteTypes {
| '/notRemountDeps'
| '/remountDeps'
| '/대한민국'
| '/params-ps/non-nested'
| '/relative/link'
| '/relative/useNavigate'
| '/onlyrouteinside'
Expand All @@ -693,6 +725,7 @@ export interface FileRouteTypes {
| '/relative'
| '/search-params'
| '/params-ps/named/$foo'
| '/params-ps/non-nested/$foo'
| '/insidelayout'
| '/subfolder/inside'
| '/layout-a'
Expand All @@ -717,6 +750,7 @@ export interface FileRouteTypes {
| '/params-ps/wildcard'
| '/redirect/$target'
| '/params-ps/named/$foo/$bar'
| '/params-ps/non-nested/$foo/$bar'
| '/relative/link/nested'
| '/relative/link/path'
| '/relative/link/with-search'
Expand All @@ -741,6 +775,7 @@ export interface FileRouteTypes {
| '/posts'
| '/remountDeps'
| '/대한민국'
| '/params-ps/non-nested'
| '/relative/link'
| '/relative/useNavigate'
| '/(another-group)/onlyrouteinside'
Expand All @@ -759,6 +794,7 @@ export interface FileRouteTypes {
| '/relative/'
| '/search-params/'
| '/params-ps/named/$foo'
| '/params-ps/non-nested/$foo_'
| '/(group)/_layout/insidelayout'
| '/(group)/subfolder/inside'
| '/_layout/_layout-2/layout-a'
Expand All @@ -783,6 +819,7 @@ export interface FileRouteTypes {
| '/params-ps/wildcard/'
| '/redirect/$target/'
| '/params-ps/named/$foo/$bar'
| '/params-ps/non-nested/$foo_/$bar'
| '/relative/link/nested/'
| '/relative/link/path/'
| '/relative/link/with-search/'
Expand All @@ -808,6 +845,7 @@ export interface RootRouteChildren {
PostsRoute: typeof PostsRouteWithChildren
RemountDepsRoute: typeof RemountDepsRoute
Char45824Char54620Char48124Char44397Route: typeof Char45824Char54620Char48124Char44397Route
ParamsPsNonNestedRouteRoute: typeof ParamsPsNonNestedRouteRouteWithChildren
RelativeLinkRouteRoute: typeof RelativeLinkRouteRouteWithChildren
RelativeUseNavigateRouteRoute: typeof RelativeUseNavigateRouteRouteWithChildren
anotherGroupOnlyrouteinsideRoute: typeof anotherGroupOnlyrouteinsideRoute
Expand Down Expand Up @@ -1030,6 +1068,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof RelativeLinkRouteRouteImport
parentRoute: typeof rootRouteImport
}
'/params-ps/non-nested': {
id: '/params-ps/non-nested'
path: '/params-ps/non-nested'
fullPath: '/params-ps/non-nested'
preLoaderRoute: typeof ParamsPsNonNestedRouteRouteImport
parentRoute: typeof rootRouteImport
}
'/redirect/$target/': {
id: '/redirect/$target/'
path: '/'
Expand Down Expand Up @@ -1191,6 +1236,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport
parentRoute: typeof groupLayoutRoute
}
'/params-ps/non-nested/$foo_': {
id: '/params-ps/non-nested/$foo_'
path: '/$foo'
fullPath: '/params-ps/non-nested/$foo'
preLoaderRoute: typeof ParamsPsNonNestedFooRouteRouteImport
parentRoute: typeof ParamsPsNonNestedRouteRoute
}
'/params-ps/named/$foo': {
id: '/params-ps/named/$foo'
path: '/params-ps/named/$foo'
Expand Down Expand Up @@ -1240,6 +1292,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof RelativeLinkNestedIndexRouteImport
parentRoute: typeof RelativeLinkRouteRoute
}
'/params-ps/non-nested/$foo_/$bar': {
id: '/params-ps/non-nested/$foo_/$bar'
path: '/$bar'
fullPath: '/params-ps/non-nested/$foo/$bar'
preLoaderRoute: typeof ParamsPsNonNestedFooBarRouteImport
parentRoute: typeof ParamsPsNonNestedFooRouteRoute
}
'/params-ps/named/$foo/$bar': {
id: '/params-ps/named/$foo/$bar'
path: '/$bar'
Expand Down Expand Up @@ -1335,6 +1394,34 @@ const PostsRouteChildren: PostsRouteChildren = {

const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren)

interface ParamsPsNonNestedFooRouteRouteChildren {
ParamsPsNonNestedFooBarRoute: typeof ParamsPsNonNestedFooBarRoute
}

const ParamsPsNonNestedFooRouteRouteChildren: ParamsPsNonNestedFooRouteRouteChildren =
{
ParamsPsNonNestedFooBarRoute: ParamsPsNonNestedFooBarRoute,
}

const ParamsPsNonNestedFooRouteRouteWithChildren =
ParamsPsNonNestedFooRouteRoute._addFileChildren(
ParamsPsNonNestedFooRouteRouteChildren,
)

interface ParamsPsNonNestedRouteRouteChildren {
ParamsPsNonNestedFooRouteRoute: typeof ParamsPsNonNestedFooRouteRouteWithChildren
}

const ParamsPsNonNestedRouteRouteChildren: ParamsPsNonNestedRouteRouteChildren =
{
ParamsPsNonNestedFooRouteRoute: ParamsPsNonNestedFooRouteRouteWithChildren,
}

const ParamsPsNonNestedRouteRouteWithChildren =
ParamsPsNonNestedRouteRoute._addFileChildren(
ParamsPsNonNestedRouteRouteChildren,
)

interface RelativeLinkRouteRouteChildren {
RelativeLinkRelativeLinkARoute: typeof RelativeLinkRelativeLinkARoute
RelativeLinkRelativeLinkBRoute: typeof RelativeLinkRelativeLinkBRoute
Expand Down Expand Up @@ -1473,6 +1560,7 @@ const rootRouteChildren: RootRouteChildren = {
RemountDepsRoute: RemountDepsRoute,
Char45824Char54620Char48124Char44397Route:
Char45824Char54620Char48124Char44397Route,
ParamsPsNonNestedRouteRoute: ParamsPsNonNestedRouteRouteWithChildren,
RelativeLinkRouteRoute: RelativeLinkRouteRouteWithChildren,
RelativeUseNavigateRouteRoute: RelativeUseNavigateRouteRouteWithChildren,
anotherGroupOnlyrouteinsideRoute: anotherGroupOnlyrouteinsideRoute,
Expand Down
12 changes: 10 additions & 2 deletions e2e/react-router/basic-file-based/src/routes/params-ps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createFileRoute } from '@tanstack/react-router'
import { Link } from '@tanstack/react-router'
import { Link, createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/params-ps/')({
component: RouteComponent,
Expand Down Expand Up @@ -69,6 +68,15 @@ function RouteComponent() {
</Link>
</li>
</ul>
<hr />
<h3 className="pb-2">Non-nested path params</h3>
<ul className="grid mb-2">
<li>
<Link data-testid="l-to-non-nested" to="/params-ps/non-nested">
Non-nested
</Link>
</li>
</ul>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createFileRoute, useParams } from '@tanstack/react-router'

export const Route = createFileRoute('/params-ps/non-nested/$foo_/$bar')({
component: RouteComponent,
})

function RouteComponent() {
const fooParams = useParams({ from: '/params-ps/non-nested/$foo_' })
const routeParams = Route.useParams()

return (
<div>
<div data-testid="foo-params-value">{JSON.stringify(fooParams)}</div>
<div data-testid="foo-bar-params-value">
{JSON.stringify(routeParams)}
</div>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/params-ps/non-nested/$foo_')()
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Link, Outlet, createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/params-ps/non-nested')({
component: RouteComponent,
})

function RouteComponent() {
return (
<div>
<h3 className="pb-2">Non-nested path params</h3>
<ul className="grid mb-2">
<li>
<Link
from={Route.fullPath}
data-testid="l-to-non-nested-foo-bar"
to="./$foo/$bar"
params={{ foo: 'foo', bar: 'bar' }}
>
/params-ps/non-nested/$foo/$bar
</Link>
</li>
</ul>
<Outlet />
</div>
)
}
Loading
Loading