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.

Attempting to get route results in Argument is not assignable to parameter of type 'keyof RouteNamedMap | undefined' #555

@SaucyJack

Description

@SaucyJack

Versions:

  • Node: 20.15.1
  • NPM: 10.7.0
  • Vue: ^3.4.29
  • vue-router: ^4.3.3
  • typescript: ~5.4.0
  • vite: ^5.3.1

unplugin-vue-router version 0.10.7

MacOS Sequoia 15.1.1
IDE: VS Code 1.96.0

I have a Vue project (composition API) with a "pages" folder structure something like this (I've omitted some aspects that are irrelevant):

src
│   App.vue
│   main.ts    
│
└───pages
│   └───dashboard
│       └───administration
│           └───automated-reports
│                │   [id].vue
│                │   index.vue
│           └───users
│                │   index.vue
│                └───[id]
│                    │   index.vue

I've reproduced this in this repository: https://github.com/SaucyJack/reproduce-ts-unplugin-router-error

in both automated-reports/[id].vue and users/[id]/index.vue, TypeScript/eslint produce an error when I attempt to get the route using vue-router, in code that looks like this:

import { useRoute } from 'vue-router'
// this produces a TS error
const route = useRoute('/dashboard/administration/automated-reports/:id')

The error is:

Argument of type '"/dashboard/administration/automated-reports/:id"' is not assignable to parameter of type 'keyof RouteNamedMap | undefined'.ts(2345)

I've run into this before and posted this SO question: https://stackoverflow.com/q/78898738/27457. I have tried all of the solutions offered there, and none of them fix the problem.

The code runs correctly with Vite using npm run dev.

It's also important to note that a friend was able to reproduce this only when he changed his Node version to 20.15.1. When he was using v18.18.2, the error did not appear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions