-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Missing named routes throw TypeErrors #1386
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
Comments
I added that label too fast, I was sure there was already a warning 😛
|
No, you misunderstand @posva. This is a bug, not an improvement. The warning is printed, this is fine. But there is also an error thrown: This issue is about that error, not the warning. |
The error happens because the link is pointing to a non-existent route, that's expected. The warning is there to help you out find the real problem |
That seems unintuitive. I would expect it to warn only (then abort), or at the very least fail gracefully with a specific error message. Instead the error message makes me think there's, well, a bug in the router. |
That's right, I'll create a pr for that. Thanks! |
* Prevent unecessary Exception with non-existent links Closes #1386 * Remove semis * Keep same behaviour in dev and pro with non-exsistent links
Maybe we should consider altering behavior a bit? IMHO using named routes should prevent regression in big projects. Atm warnings only pop up if user visits a page with invalid route link. I'm not sure if |
You could implement a webpack plugin for it but I think the current behaviour is already easy to detect because of the warnings/errors |
Version
2.5.2
Reproduction link
http://jsfiddle.net/qkco53b9/1/
Steps to reproduce
Run the example. Look at the console.
What is expected?
Inserting a router link to a named route that doesn't exist should warn.
What is actually happening?
The console spews both warnings about the missing named routes and errors about not being able to access the
regex
property of a route.I'm building an SPA and inserting placeholder links to pages I haven't built yet.
It looks like the problem might be here:
vue-router/src/create-matcher.js
Line 39 in 4de549a
The text was updated successfully, but these errors were encountered: