victorgarciaesgi / nuxt-typed-router

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

Allow linking to nested pages with current params set by default #140

Open tdolsen opened 5 months ago

tdolsen commented 5 months ago

Describe the bug When using NuxtLink to link to nested sub pages from a page with params, those params are not identified as defaults, and have to be redefined in :to.

Expected behavior As with how RouterLink/NuxtLink actually works, I expect the typed overload to identify which params are available for a given page, and make those params optional when using NuxtLink.

Screenshots pages/okr/ice/index.vue: image

Environnement infos

Your pages folder structure

pages
├── index.vue
└── okr
    └── ice
        └── [id]
            ├── index.vue
            └── respond.vue

Your nuxt.config.ts

export default defineNuxtConfig({
    devtools: { enabled: true },
    modules: ["nuxt-typed-router"],
});
victorgarciaesgi commented 5 months ago

Hi!

I explain it here: https://nuxt-typed-router.vercel.app/usage/how-to-use#pagesnestedtitleuseridindexvue

As the type system cannot know where you're navigating from, it's not really possible. You could be navigating from any other non-nested pages and the params should be required.

It's a complicated case