victorgarciaesgi / nuxt-typed-router

🚦Provide autocompletion and typecheck to Nuxt router
https://nuxt-typed-router.vercel.app
MIT License
354 stars 12 forks source link

Issues with types on `useRoute` #108

Closed 9M6 closed 1 year ago

9M6 commented 1 year ago

Describe the bug I am getting type issues: Volar: '__VLS_ctx.route.params' is of type 'unknown'. when using the composable useRoute()

Expected behavior

It should not show any type error, and the types should be correctly inferred.

Screenshots

CleanShot 2023-07-19 at 11 47 05@2x

Environnement infos

Nuxt project info: (copied to clipboard)                                                                                           11:48:56 AM

------------------------------
- Operating System: Darwin
- Node Version:     v18.16.0
- Nuxt Version:     3.6.3
- Nitro Version:    2.5.2
- Package Manager:  npm@9.5.1
- Builder:          vite
- User Config:      experimental, vite, nitro, devtools, debug, ssr, css, imports, runtimeConfig, modules, apiParty
- Runtime Modules:  @pinia/nuxt@0.4.11, @nuxtjs/tailwindcss@6.8.0, @nuxtjs/i18n@8.0.0-beta.13, @vueuse/nuxt@10.2.1, nuxt-typed-router@3.2.5, nuxt-lodash@2.5.0, nuxt-api-party@0.13.0, nuxt-icon@0.4.2
- Build Modules:    -

Your pages folder structure

Run npx tree-node-cli {your page folder path}

Your nuxt.config.ts Paste your modules config (and i18n config if you're using it)

victorgarciaesgi commented 1 year ago

Can you show me how you use useRoute in the script? From where do you import it?

9M6 commented 1 year ago

@victorgarciaesgi autoimport from nuxt.

victorgarciaesgi commented 1 year ago

I still need to see how you use it or more info, otherwise i can't find the problem

9M6 commented 1 year ago
CleanShot 2023-07-19 at 15 51 48@2x

@victorgarciaesgi

victorgarciaesgi commented 1 year ago

useRoute is strongly typed, and can't guess which page you're in. You need to provide the route name

https://nuxt-typed-router.vercel.app/usage/useroute

9M6 commented 1 year ago

Oh I see, I thought this would be by default for some reason. Got it! Thank you @victorgarciaesgi