vuejs / router

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

Make `params` required in route location types if a typed route has required params to prevent runtime errors #2372

Closed Anoesj closed 4 hours ago

Anoesj commented 4 hours ago

Reproduction

https://stackblitz.com/edit/github-woay8w-tedisk?file=composables%2FuseSomeRouteComposable.ts

Steps to reproduce the bug

Expected behavior

TypeScript raises an error, just like it does when providing params but as an empty object, or an object with other properties than the actual required params.

Actual behavior

TypeScript does not show any errors when omitting the params object, when the typed route has required route params. In the runtime, this does result in an error though.

Additional information

Developers use TypeScript to prevent runtime errors. If we fix this, we help preventing runtime errors.

posva commented 4 hours ago

This is already tracked in unplugin-vue-router

Anoesj commented 3 hours ago

@posva Could you link the corresponding issue? Is it this one? https://github.com/posva/unplugin-vue-router/issues/285

posva commented 1 hour ago

Duplicate of https://github.com/posva/unplugin-vue-router/issues/285