Skip to content

Commit d485cc2

Browse files
mkarajohnnlynzaad
andauthored
fix(router-core): type mismatch for navigate function (#4625)
According to the docs this should only return a promise https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType#navigate-method Makes sense otherwise you cannot .then() it --------- Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
1 parent be1b9e3 commit d485cc2

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/react-router/src/link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export function useLinkProps<
276276

277277
// All is well? Navigate!
278278
// N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing
279-
return router.navigate({
279+
router.navigate({
280280
...options,
281281
from,
282282
replace,

packages/router-core/src/RouterProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type NavigateFn = <
3030
TMaskTo extends string = '',
3131
>(
3232
opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
33-
) => Promise<void> | void
33+
) => Promise<void>
3434

3535
export type BuildLocationFn = <
3636
TRouter extends RegisteredRouter,

packages/router-core/src/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ export class RouterCore<
17551755
} else {
17561756
window.location.href = href
17571757
}
1758-
return
1758+
return Promise.resolve()
17591759
}
17601760

17611761
return this.buildAndCommitLocation({

packages/solid-router/src/link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export function useLinkProps<
286286

287287
// All is well? Navigate!
288288
// N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing
289-
return router.navigate({
289+
router.navigate({
290290
..._options(),
291291
replace: local.replace,
292292
resetScroll: local.resetScroll,

0 commit comments

Comments
 (0)