vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.74k stars 1.15k forks source link

await doesn't work for router.go() but does for router.push()? #2261

Closed gureckis closed 1 month ago

gureckis commented 1 month ago

Reproduction

it is a documentation issue

Steps to reproduce the bug

await router.push({ name: view })

works as expected based on the docs.

await router.go(-1)

does not (also generates Typescript warning).

The docs on programmatic navigation and "Waiting for the results of a Navigation" don't really make this difference clear. Is is possible for both to be await-able?

Expected behavior

Both router.push() and router.go() would work with await.

Actual behavior

Only router.push() can be awaited.

Additional information

No response

posva commented 1 month ago

Unfortunately this is a technical limitation of the history api