-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
$route.meta types #2331
Comments
The meta object can be different per route, otherwise, its type would end up in making every single field optional, forcing you to check everytime the properties |
But we dont even have this decision... Also some structure like this reduces the checks to a minimum: interface RouteMeta {
navigation?: RouteNavigation,
auth?: RouteAuth,
} The check doesnt change at all, if we want to check RouteAuth in a hook, because i need to check for |
@posva I agree with @backbone87. Providing an imperfect but still working ability to declare The main potential problem I can see there is that the implementation of this feature would not be as easy as it seems to be. Vue-router itself creates ambient type declarations for Vue with |
Let's keep the discussion at #3183 |
What problem does this feature solve?
Currently the
meta
field is typed to any. It would be nice, if we could provide a type for it. I tried an ambient module, but couldnt get it to work, so a generic type variable may needs to be introduced.What does the proposed API look like?
interface RouteConfig<M = any> { meta?: M, ... }
Also the using types may need adjustments.
The text was updated successfully, but these errors were encountered: