Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all routes in generated type "RoutesNamesList" #87

Closed
SimonSimCity opened this issue Apr 22, 2023 · 11 comments
Closed

Not all routes in generated type "RoutesNamesList" #87

SimonSimCity opened this issue Apr 22, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@SimonSimCity
Copy link

In my project, I discovered that the type definition for RoutesNamesList only contains the first 3 of my pages, where the last one is index. Folders seem to be skipped as well as the files below index.

nuxt-typed-router: 3.1.4
nuxt: 3.4.2

Any idea of how I can get more information during nuxt prepare? I guess its some problem in there ...

@SimonSimCity
Copy link
Author

SimonSimCity commented Apr 22, 2023

Seems the reason for this in my case is the fact that I have an index.vue file inside the pages folder. After removing it, all routes are generated as expected.

Here's the output of ls pages/*/* which shows you the pages I have in my project:

pages/audiobooks.vue            pages/index.vue                 pages/not-found.vue             pages/playlist/private/[id].vue
pages/browse.vue                pages/messages.vue              pages/playlist/curated/[id].vue pages/search.vue

With this setup, I get the following type:

export type RoutesNamedLocations = { name: 'audiobooks' } | { name: 'browse' } | { name: 'index' };

After removing pages/index.vue the following type is generated:

export type RoutesNamedLocations =
  | { name: 'audiobooks' }
  | { name: 'browse' }
  | { name: 'messages' }
  | { name: 'not-found' }
  | {
      name: 'playlist-curated-id';
      params: {
        id: string | number;
      };
    }
  | {
      name: 'playlist-private-id';
      params: {
        id: string | number;
      };
    }
  | { name: 'search' };

Which is as I need it 😅

All those files have the following code:

<script lang="ts" setup>
</script>

<template>
  <div>
  </div>
</template>

Please let me know if there's any other information that might be helpful.

EDIT:
I've now set up a minimal reproducible setup. It is a plain nuxt3 installation where I removed the app.vue, added my pages folder and added @nuxtjs/i18n in its latest version 8.0.0-beta.11 and this plugin nuxt-typed-router v3.1.4. When using both plugins, this one only generates routes as listed above.

Here's the repo: https://github.com/SimonSimCity/nuxt-typed-routes-bug

@victorgarciaesgi
Copy link
Owner

Hi! Thanks for the details. Indeed that's a weird ouput
As for implementation details, I'm mapping over what Nuxt generates, so everything that comes out is only what Nuxt outputs, i will try to reproduce it thanks for the repo! :D

@victorgarciaesgi
Copy link
Owner

Maybe a problem with @nuxtjs/i18n i'll investigate

@victorgarciaesgi
Copy link
Owner

Found the cause, will publish a patch shortly

@victorgarciaesgi
Copy link
Owner

You can try on 3.1.5

@SimonSimCity
Copy link
Author

SimonSimCity commented Apr 23, 2023

Well, that doesn't really fix it in my particular case. I have the some settings set for i18n just not in my example 😇

When setting the property strategy to no_prefix it works, but when not defining it, or setting it to another value, it doesn't.

I've updated the repo accordingly - the changes chan be found in this commit: SimonSimCity/nuxt-typed-routes-bug@1fe1570

@SimonSimCity
Copy link
Author

This isn't so relevant for me, as I need to set strategy to no_prefix, but still would be nice for other people to fully support these other options as well or add a note about it 😏

@victorgarciaesgi
Copy link
Owner

Weird! It's supposed to support all strategies, but as Nuxt made breaking changes in 3.4 maybe the nuxjs/i18n plugin isn't updated yet to support it either

@victorgarciaesgi
Copy link
Owner

Okay the module changes it's default strategy, now it's prefix_execpt_default.
Publish the changes on a minor version because there may be breaking changes
3.2.0-beta.0 if you can try it

@victorgarciaesgi victorgarciaesgi added the bug Something isn't working label Apr 24, 2023
@victorgarciaesgi
Copy link
Owner

@SimonSimCity is it working for you with the beta version?

@SimonSimCity
Copy link
Author

Yepp, works 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants