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

[typescript] Incompatible Route and Location types #3139

Closed
victortwc opened this issue Mar 4, 2020 · 1 comment
Closed

[typescript] Incompatible Route and Location types #3139

victortwc opened this issue Mar 4, 2020 · 1 comment

Comments

@victortwc
Copy link

victortwc commented Mar 4, 2020

Version

3.1.6

Reproduction link

http://shorturl.at/ixJQ5

Steps to reproduce

this.$router.push({
    ...this.$route, 
    params: {
        newParam: true
    }
})

With typescript, it breaks.

What is expected?

Route and Location types are compatible.

What is actually happening?

As Route now have the name parameter with string | null | undefined it breaks the navigation, as Location will only accept string | undefined as name.


Commit causing the issue:
8f831f2

@posva
Copy link
Member

posva commented Mar 4, 2020

The types are indeed not compatible: null can exist as a value of Route but when providing a Location with methods like push and replace, null is not valid name. FYI, there are a few other things that cannot be passed like fullPath. In general, spreading $route to a push/replace is a bad idea because it's a normalised location and it contains more information than a Location

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