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

route state not compatible with typing definition from vue router #84

Open
axe-me opened this issue Jun 27, 2018 · 5 comments
Open

route state not compatible with typing definition from vue router #84

axe-me opened this issue Jun 27, 2018 · 5 comments

Comments

@axe-me
Copy link

axe-me commented Jun 27, 2018

  import { Route } from "vue-router";

  @Watch("route")
  onRouteChanged(currRoute: Route) {
    if (currRoute.meta.parentRoute) {
      // got ts error at this line saying: 'Property 'from' does not exist on type 'Route'.'
      this.buttonText = currRoute.from.name;
      this.routeName = null;
      this.show = true;
    } else {
      this.show = false;
    }
  }

prob should define a route typing for the state in this library?

@axe-me
Copy link
Author

axe-me commented Jun 27, 2018

i will just shim it for now i guess,

import { Route } from "vue-router";
export interface RouteState extends Route {
  from: Route;
}

@LinusBorg
Copy link
Member

This issue seems to be about vue-router, not vuex-router-sync?

@posva
Copy link
Member

posva commented Jul 3, 2018

There's no from in Route type

@posva posva closed this as completed Jul 3, 2018
@axe-me
Copy link
Author

axe-me commented Jul 3, 2018

@posva that is the problem, no from in route type, but the store state has it: https://github.com/vuejs/vuex-router-sync/blob/master/src/index.js#L71 , and @LinusBorg I don't think this is a issue for vue-router, since this library bind the from property on the route object.

thus I believe we should shim it in the type definition file here https://github.com/vuejs/vuex-router-sync/blob/master/types/index.d.ts

i can make a PR if you guys think this is the right way to do, i have to shim it in my app anyway.

@posva
Copy link
Member

posva commented Jul 4, 2018

Ah, I see but don't add it to the Route type since it's only available in store module. Worst case is creating a new type and exporting it

@posva posva reopened this Jul 4, 2018
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

3 participants