Skip to content

int paramParser not modifying value #2621

@OwenVey

Description

@OwenVey

Reproduction

https://github.com/OwenVey/vue-router-int-parser

Steps to reproduce the bug

I have a route file [id=int].vue and route.params.id has a type of number but when I log it or log the typeof I am seeing that it is actually a string.

My vite.config.ts file looks like:

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import VueRouter from 'vue-router/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    VueRouter({
      dts: './src/route-map.d.ts',
      experimental: {
        paramParsers: true
      }
    }),
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})

Expected behavior

The value of route.params.id should be a number

Actual behavior

The value of route.params.id is a string

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions