nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

$getRouteBaseName CommonComposableOptions error WTF #2864

Closed provok-me closed 6 months ago

provok-me commented 6 months ago

Environment


Reproduction

...

Describe the bug

You forgot to wrap getRouteBaseName with wrapComposable here in your code.

This results in $getRouteBaseName failing because the common argument is missing.

// This throws an error.
const routeBaseNameTest1 = $getRouteBaseName(specificRoute);

// This throws an error too.
const routeBaseNameTest2 = $getRouteBaseName();

Additional context

Add tests to the code base to avoid pushing error-prone code. (It's been a problem multiple times from the start with v8)

Logs

No response

github-actions[bot] commented 6 months ago

Would you be able to provide a reproduction? πŸ™

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: πŸ‘‰ [Reproduction starter (v8 and higher)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/v8) πŸ‘‰ [Reproduction starter (edge)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/edge) A public GitHub repository is also perfect. πŸ‘Œ Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)
BobbieGoede commented 6 months ago

At first glance it looks like you're right, will look into it but a repro is always helpful.

provok-me commented 5 months ago

@BobbieGoede

I updated to v8.3.0.

Now it's the Typescript definition of getRouteBaseName that's wrong (and thus the definition of $getRouteBaseName is wrong too.)

You'll find the wrong definition in the following generated file: dist/runtime/routing/compatibles/routing.d.ts

The problem comes from the changes made to getRouteBaseName in the following commit (see line 50 of src/runtime/routing/compatibles/routing.ts): https://github.com/nuxt-modules/i18n/commit/b0016471c617ece151ac1d2f3195f3bd4b0b3bc7

Do you have a strategy to avoid rollbacks for future module versions?

BobbieGoede commented 5 months ago

Feel free to open a PR!