Vetur template interpolation: How can I setup global virtual method for template by JsDoc? Without typescript

397 views Asked by At

I registered i18n in Nuxt. But I can use it without errors. Interpolation didn't see $t method. How can I fix it?

For types in templates I use only JsDoc

enter image description here

Compiling actually works, but I don't want to see the error

Error: Property '$t' does not exist on type 'CombinedVueInstance<{ openedSubMenuId: any; } & { openSub(id: any): void; closeSub(): void; } & { nav: NavItem[]; value: boolean; } & Vue, object, object, object, Record<never, any>>'

enter image description here

Nuxt config

export default {
  head: {
    title: 'nuxt-football',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  css: ['@/assets/scss/_vars.scss', '@/assets/scss/main.scss'],

  styleResources: {
    scss: ['./assets/scss/*.scss'],
  },

  plugins: [],

  components: {
    dirs: [
      '~/components',
      {
        path: '~/components/App/',
      },
    ],
  },

  buildModules: ['@nuxtjs/eslint-module'],

  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    '@nuxtjs/style-resources',
    'nuxt-i18n',
  ],

  i18n: {
    defaultLocale: 'ru',

    locales: [
      {
        code: 'ru',
        file: 'ru-Ru.js',
      },
    ],
    lazy: true,
    langDir: 'lang/',
  },

  axios: {},

  build: {},
};

1

There are 1 answers

0
Michael Gitart On BEST ANSWER

You need to add it to tsconfig (if you are using nuxt):

{
  "compilerOptions": {
    "types": ["@nuxt/types", "nuxt-i18n"]
  }
}