vuejs / vue-router

🚦 The official router for Vue 2
http://v3.router.vuejs.org/
MIT License
18.99k stars 5.06k forks source link

TS throwing "missing param for named route..." when param is empty string and runtime error when is empty string #3838

Closed VividLemon closed 1 year ago

VividLemon commented 1 year ago

This is the original issue, I linked it in the wrong location https://github.com/vuejs/router/issues/1801#issue-1671578700

I created a reproduction https://github.com/VividLemon/vue-router-issue

Here is the issue in summary:

When you do this.$router.push( { name: 'about', params: { id: undefined } } ). This works, but throws a TS error

When you do this.$router.push( { name: 'about', params: { id: '' } } ), this does NOT work, but throws no error.

It will "appear" as if it works (for the second) but will not actually change the URL, and will throw a console warn.

This issue does not occur for vue-router@4 & vue 3