Vue-router: Missing TS definition for router push

Created on 7 Apr 2017  ·  3Comments  ·  Source: vuejs/vue-router

Version

2.3.0

Reproduction link

https://jsfiddle.net/7syt1bdu/

Steps to reproduce

When writing router.push({name: 'xx', params: {id: 2}} TS will complain about the type is not right.

What is expected?

Problem free TS compilation :-)

What is actually happening?

TS error


adding this to types/router.d.ts, fix the issue :

export interface LocationObject {
    name?: string,
    path?: string,
    params?: Object
    query?: Object
}
export type RawLocation = string | Location | LocationObject;
improvement

Most helpful comment

Location params and query may only hold string values, and I passed along a number. Sorry, move on ... nothing to see :-)

All 3 comments

A PR would be even better 🙂

Ok, i make the PR danse 😁

Location params and query may only hold string values, and I passed along a number. Sorry, move on ... nothing to see :-)

Was this page helpful?
0 / 5 - 0 ratings