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

Types: Missing options on instance.$router #3151

Closed
Mister-Hope opened this issue Mar 20, 2020 · 4 comments
Closed

Types: Missing options on instance.$router #3151

Mister-Hope opened this issue Mar 20, 2020 · 4 comments

Comments

@Mister-Hope
Copy link

Version

3.1.6

Steps to reproduce

this.$router.options // should be the options that user passed to vue-rotuer

Solution

I think we should change

declare module 'vue/types/vue' {
  interface Vue {
    $router: VueRouter
    $route: Route
  }
}

to

import { RouterOptions } from './router'

declare module 'vue/types/vue' {
  interface Vue {
    $router: VueRouter & { options: RouterOptions }
    $route: Route
  }
}
@posva
Copy link
Member

posva commented Mar 20, 2020

As said in #2051, it's a private API. What do you need to read from $options?

@Mister-Hope
Copy link
Author

Mister-Hope commented Mar 21, 2020

routes.

I am making a plugin, so I am not expecting that the user provides me his options.

@posva
Copy link
Member

posva commented Mar 21, 2020

I see. Retrieving the routes is the only thing I've seen so far and it will be covered by vuejs/rfcs#122. While dynamic routing won't added to vue router 3, it's possible to add the getRoutes function here to retrieve the list of records once that RFC reaches a final comments state. It will also have routes dynamically added by the user in a normalised format, which is not the case for router.options

@posva posva closed this as completed Mar 21, 2020
@Mister-Hope
Copy link
Author

I see. Retrieving the routes is the only thing I've seen so far and it will be covered by vuejs/rfcs#122. While dynamic routing won't added to vue router 3, it's possible to add the getRoutes function here to retrieve the list of records once that RFC reaches a final comments state. It will also have routes dynamically added by the user in a normalised format, which is not the case for router.options

Wow, getRoutes function is pretty cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants