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

With vue-i18n it gives types error of $t and $i18n usage #3760

Closed
dhavalt091 opened this issue Nov 29, 2023 · 16 comments
Closed

With vue-i18n it gives types error of $t and $i18n usage #3760

dhavalt091 opened this issue Nov 29, 2023 · 16 comments

Comments

@dhavalt091
Copy link

As soon as i enable/install Vue Language Features (Volar) in VS code, i get type errors in html wherever $t and $i18n is used.

<template> <h1>{{ $t('views.home.title') }}</h1> <h1>{{ $i18n.locale }}</h1> </template>
Above is my html.

And below is how i get errors/warnings by volar.

volar-html

What am i missing here?

@UfukUstali
Copy link

It might be related to this I am not sure tough.

nuxt-modules/i18n#2483 (comment)

@Nick-Hopps
Copy link

the same issue #3735

@rchl
Copy link
Collaborator

rchl commented Nov 30, 2023

There were issues with types unrelated to Volar, as the linked issue states.
Please provide a repo that reproduces and also make sure you are using latest versions of the module.

@so1ve
Copy link
Member

so1ve commented Nov 30, 2023

Duplicate of #3735

@so1ve so1ve marked this as a duplicate of #3735 Nov 30, 2023
@so1ve so1ve closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@so1ve so1ve added the duplicate This issue or pull request already exists label Nov 30, 2023
@rchl
Copy link
Collaborator

rchl commented Nov 30, 2023

I'm not sure if those are duplicates. One is using nuxt module and one is using (older) version of vue-i18n

@so1ve
Copy link
Member

so1ve commented Nov 30, 2023

Sorry, didn't notice that 😅 I'll reopen this issue to investigate further

@so1ve so1ve reopened this Nov 30, 2023
@so1ve so1ve added pending triage and removed duplicate This issue or pull request already exists labels Nov 30, 2023
@rchl
Copy link
Collaborator

rchl commented Nov 30, 2023

We should wait for reproduction instead of investigating as there were known issues with types in i18n nuxt module that might be fixed already.

@so1ve
Copy link
Member

so1ve commented Nov 30, 2023

So I added the pending triage label to wait for @dhavalt091's input :)

@dhavalt091
Copy link
Author

It might be related to this I am not sure tough.

nuxt-modules/i18n#2483 (comment)

I am using Vue 3. Not nuxt.

@UfukUstali
Copy link

The issue mentioned in that comment was caused by Vue i18n which nuxt i18n does also use under the hood.

@dhavalt091
Copy link
Author

Using below versions.

 "vue": "^3.2.47",
 "vue-i18n": "^9.2.2",

Vue Language Features (Volar) v1.8.24

In Home.vue with just simple usage it's reproducible.

<template>
    <h1>{{ $t('views.home') }}</h1>
    <h1>{{ $i18n.locale }}</h1>
</template>

This is nothing related to nuxt

@rchl
Copy link
Collaborator

rchl commented Nov 30, 2023

In Home.vue with just simple usage it's reproducible.

Provide a repo that reproduces.
It's relevant how the project is set up. The specific component you are showing is not enough.
And if vue-i18n itself doesn't extend Vue types then it would be your responsibility to do that, not Volar's.

It might be a better question for the vue-i18n repo, to be honest.

@dhavalt091
Copy link
Author

If error highlights without this extension then it would be vue-i18n repo.
I have just above template in Home.vue file. No script ta as well. This is enough to reproduce the issue.
How can i create reproduction repo? Online tools like stackblitz doesn't provide a way to add extension in it.

@rchl
Copy link
Collaborator

rchl commented Nov 30, 2023

No, just a snippet of code is not enough. It's also relevant which packages are installed and in what versions. And the tsconfig.json configuration. And many other variables...

Just create a project that reproduces and put it on stackblitz or github. Then someone can download it locally and check with Volar.

@Nick-Hopps
Copy link

Nick-Hopps commented Dec 1, 2023

Because I have a monorepo with [email protected] installed, and the main version I use is [email protected]. The package '@vue/runtime-core' under the root node_modules belongs to 3.2.47, and 'vue/node_modules' /@vue/runtime-core' is what 3.3.4 actually uses. So the type definition of vue-i18n does not take effect

@Nick-Hopps
Copy link

I don't know how to configure npm workspace to force installing sub package's vue inside their respective node_modules, so I just remove workspaces config in the root package.json and run npm install then add the config back and run npm install -w packages/*, once the "@vue/runtime-core" version under root project is ok, the issue will be gone.

@kermanx kermanx closed this as completed Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants