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
15 changes: 7 additions & 8 deletions packages/react-router/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ export type Last<T extends Array<any>> = T extends [...infer _, infer L]
? L
: never

export type RemoveTrailingSlashes<T> = T extends '/'
? T
: T extends `${infer R}/`
? RemoveTrailingSlashes<R>
: T
export type RemoveTrailingSlashes<T> = T extends `${infer R}/`
? RemoveTrailingSlashes<R>
: T

export type RemoveLeadingSlashes<T> = T extends `/${infer R}`
? RemoveLeadingSlashes<R>
Expand Down Expand Up @@ -217,10 +215,11 @@ export type ResolveRoute<
? TFrom
: ResolveRelativePath<TFrom, TTo>
>,
> =
RouteByPath<TRouteTree, `${TPath & string}/`> extends never
> = TPath extends string
? RouteByPath<TRouteTree, `${TPath}/`> extends never
? RouteByPath<TRouteTree, TPath>
: RouteByPath<TRouteTree, `${TPath & string}/`>
: RouteByPath<TRouteTree, `${TPath}/`>
: never

type PostProcessParams<
T,
Expand Down
9 changes: 5 additions & 4 deletions packages/react-router/tests/fileRoute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createFileRoute,
createLazyRoute,
createLazyFileRoute,
LazyRoute,
} from '../src'

describe('createFileRoute has the same hooks as getRouteApi', () => {
Expand All @@ -16,7 +17,7 @@ describe('createFileRoute has the same hooks as getRouteApi', () => {
it.each(hookNames.map((name) => [name]))(
'should have the "%s" hook defined',
(hookName) => {
expect(route[hookName]).toBeDefined()
expect(hookName as keyof LazyRoute<any>).toBeDefined()
},
)
})
Expand All @@ -30,20 +31,20 @@ describe('createLazyFileRoute has the same hooks as getRouteApi', () => {
it.each(hookNames.map((name) => [name]))(
'should have the "%s" hook defined',
(hookName) => {
expect(route[hookName]).toBeDefined()
expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
},
)
})

describe('createLazyRoute has the same hooks as getRouteApi', () => {
const routeApi = getRouteApi('foo')
const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
const route = createLazyRoute({})({})
const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))

it.each(hookNames.map((name) => [name]))(
'should have the "%s" hook defined',
(hookName) => {
expect(route[hookName]).toBeDefined()
expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
},
)
})
Loading