Skip to content
Open
Changes from 2 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
21 changes: 21 additions & 0 deletions packages/router-core/src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,19 @@ export class BaseRoute<
)
}

if (process.env.NODE_ENV !== 'production') {
if (
this.parentRoute &&
!this.parentRoute.isRoot &&
this.parentRoute.fullPath.endsWith('/')
) {
invariant(
false,
`Parent route with id '${this.parentRoute.id}' returned by getParentRoute on '${this.id}' is an index route and cannot have child routes.`,
)
}
}

let path: undefined | string = isRoot ? rootRouteId : options?.path

// If the path is anything other than an index path, trim it up
Expand Down Expand Up @@ -1728,6 +1741,14 @@ export class BaseRoute<
TServerMiddlewares,
THandlers
> = (children) => {
if (process.env.NODE_ENV !== 'production') {
if (!this.isRoot && this.fullPath.endsWith('/')) {
invariant(
false,
`Cannot add children to index route '${this.id}'. Index routes cannot have child routes.`,
)
}
}
return this._addFileChildren(children) as any
}

Expand Down
Loading