Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

[Feature Request] Automatically type definePage({ redirect: (to) => [...] }) with a volar plugin #684

@darkbasic

Description

@darkbasic

In addition to useRoute() I think that definePage's redirect to param should be automatically typed as well:

definePage({
  redirect: (to) => ({
    name: '/members/[id]/roles',
    // params: { id: route.params.id }
    // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- we know where we are
    params: { id: (to.params as RouteNamedMap['/members/[id]']['params']).id }
  })
})

That's because you can't refer to useRoute inside definePage or you will get the following error:

  [unplugin-vue-router] `definePage()` in <script setup> cannot reference locally declared variables (route) because it will be hoisted outside of the setup() function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions