Skip to content

Extending RouterLink example does not compile in TypeScript #1429

Open
@TheDutchCoder

Description

@TheDutchCoder

Version

4.0.15

Reproduction link

stackblitz.com

Steps to reproduce

There's an issue with reactivity in the template when extending the routerlink as per example from the docs: https://router.vuejs.org/guide/advanced/extending-router-link.html

The culprit is the ...RouterLink.props prop spread, which (for some reason) makes props unavailable to the template unless you destructure the props with toRefs.

I'm not sure if this a bug in vue-router, a bug in vue, or a limitation/side-effect in general, but the example won't properly build and will throw TS errors (it also throws errors in dev, as you can see in the reproduction).

Uncomment the commented out line with toRefs to make it all work.

What is expected?

Props to be available in the template with having to destructure them and use toRefs

What is actually happening?

Due to ...RouterLink.props the props are no longer directly available in the template.


Again: not sure if it's a bug, or a limitation of sorts.
At least it would be good to add this to the docs if it isn't a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsConcerns the documentation content or the documentation websiteenhancementNew feature or requesttypescriptProblem related to TS typings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions