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

Type error '__VLS_ctx.$t' is of type 'unknown'. #3271

Closed
IgorKha opened this issue Dec 20, 2024 · 7 comments
Closed

Type error '__VLS_ctx.$t' is of type 'unknown'. #3271

IgorKha opened this issue Dec 20, 2024 · 7 comments

Comments

@IgorKha
Copy link

IgorKha commented Dec 20, 2024

Environment



export default defineNuxtConfig({
  compatibilityDate: "2024-11-01",
  devtools: { enabled: true },

  modules: ["@pinia/nuxt", "@nuxt/eslint", "@nuxtjs/i18n"],
  i18n: {
    debug: true,
    types: 'composition',
    strategy: 'no_prefix',
    defaultLocale: 'en',
    lazy: true,
    langDir: 'locales',
    locales: [
      {
        name: 'English',
        code: 'en',
        language: 'en-GB',
        file: 'en-GB.json',
      },
    ],
  },

  future: {
    compatibilityVersion: 4,
  },

Reproduction

I don't know how reproduce this problem in online services

Describe the bug

With this configuration on a clean project I get this typing error: '__VLS_ctx.$t' is of type 'unknown'.

Image

Additional context

No response

Logs

Copy link

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)
👉 Reproduction starter (edge)

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@BobbieGoede
Copy link
Collaborator

I don't know how reproduce this problem in online services

A Github repo of a minimal reproduction project will be sufficient too 🙏

@IgorKha
Copy link
Author

IgorKha commented Dec 21, 2024

@BobbieGoede yes, this simple repo

https://github.com/IgorKha/nuxt3-i18n-type-repr-issue

Image

thank you!

@BobbieGoede
Copy link
Collaborator

BobbieGoede commented Dec 21, 2024

@IgorKha
It looks like you have an old release candidate of this module installed (^9.0.0-rc.2), updating to latest (npm i -D @nuxtjs/i18n@latest) should resolve your issue, you may need to refresh lockfiles and/or restart ts language server after installation.

@IgorKha
Copy link
Author

IgorKha commented Dec 21, 2024

@BobbieGoede
unfortunately it didn't work.
What I did.

  1. updated as you recommended
  2. Run npx nuxi cleanup.
  3. Deleted node_modules
  4. Restarted the IDE
  5. Reinstalled modules npm i
  6. Restarted the IDE again.
Image

I also disabled all plugins and deleted the IDE configuration to make sure the problem is not with third-party plugins or settings

@IgorKha
Copy link
Author

IgorKha commented Dec 21, 2024

I found the root of the problem
it's related to this problem, so please forgive me for wasting your time.
tldt: you need to explicitly enable hybrid mode for vue.volar

{
  "vue.server.hybridMode": true
}

vuejs/language-tools#4206

@IgorKha IgorKha closed this as completed Dec 21, 2024
@userquin
Copy link
Collaborator

In my case it is copilot plugin:

Image

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

3 participants