Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Anoesj opened this issue Sep 27, 2024 · 3 comments

Comments

@Anoesj
Copy link

Anoesj commented Sep 27, 2024

Reproduction

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

Steps to reproduce the bug

  • Open or start a project that uses the typed router
  • Call router.resolve() / router().push() / router().replace() etcetera with { name: 'any-route-that-requires-params' } and omit the params object.
  • TypeScript does not raise an error.

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
Copy link
Member

posva commented Sep 27, 2024

This is already tracked in unplugin-vue-router

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2024
@Anoesj
Copy link
Author

Anoesj commented Sep 27, 2024

@posva Could you link the corresponding issue? Is it this one? posva/unplugin-vue-router#285

@posva
Copy link
Member

posva commented Sep 27, 2024

Duplicate of posva/unplugin-vue-router#285

@posva posva marked this as a duplicate of posva/unplugin-vue-router#285 Sep 27, 2024
@vuejs vuejs locked and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants