i18n icon indicating copy to clipboard operation
i18n copied to clipboard

using @nuxt/i18n global mixin localePath typeScript error

Open AwesomeAnders opened this issue 3 years ago • 3 comments

Environment

Development

Reproduction

<NuxtLink :to="localePath(item.link)">

Describe the bug

https://i18n.nuxtjs.org/basic-usage#nuxt-link

When using the localePath mixin as described you will get typeScript error:

Property 'localePath' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{ variant: "link" | "button" | "img"; }> & Omit<Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, { ...; }>>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, "variant">; ... 10 more ...; $watch<T extends string |...'. Did you mean 'useLocalePath'?ts(2551) imports.d.ts(251, 14): 'useLocalePath' is declared here.

Additional context

No response

Logs

No response

AwesomeAnders avatar Apr 20 '23 14:04 AwesomeAnders

It's hard to say what could be causing the issue without a reproduction or information about your dev environment. Based on the error it seems like you may be using the beta version of this module but the documentation link is for v7. Is your project Nuxt 2 or Nuxt 3? And which version of this module are you using?

BobbieGoede avatar Apr 20 '23 16:04 BobbieGoede

The documentation link i provided is for the version v8.0.0-beta.7

Link to a repo reproducing this: https://github.com/AwesomeAnders/my-app clone the repo and oberserve the typescript error when using localePath on the index page

image

I'm new to typescript so perhaps I'm misunderstanding how you're supposed to use this localePath mixin

AwesomeAnders avatar Apr 21 '23 07:04 AwesomeAnders

Turns out I'm a donkey and have been looking at the wrong documentation.

I thought this was indicating the version of the documentation and not a link to release changes image

Looking at the correct documentation: https://v8.i18n.nuxtjs.org/getting-started/basic-usage

I can now see my problem is no longer relevant.

AwesomeAnders avatar Apr 21 '23 10:04 AwesomeAnders