vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Resource Keys completion does not work with global messages and $t

Open yannbriancon opened this issue 1 year ago • 3 comments

Reporting a bug?

When using global definitions and $t, key completion (and type checking) does not work.

Here is the declaration file I use:

import { DefineLocaleMessage } from 'vue-i18n'

declare module 'vue-i18n' {
    // define the locale messages schema
    export interface DefineLocaleMessage {
        test: string
    }
}

I set it up like this:

export const i18n = createI18n<false>({
    messages,
    numberFormats,
    legacy: false,
    locale: defaultLocale,
    fallbackLocale: defaultLocale
})

Then in a component I try to type in but nothing appears: image

Expected behavior

Resource completion should work if I understood the doc correctly. Should type checking work too?

Reproduction

Enough information.

System Info

System:
    OS: macOS 12.4
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 104.0.5112.79
    Firefox: 103.0.2
    Safari: 15.5
    Safari Technology Preview: 16.0
  npmPackages:
    @intlify/devtools-if: ^9.1.9 => 9.2.2 
    @intlify/vue-devtools: ^9.1.9 => 9.2.2 
    @vitejs/plugin-vue: ^1.9.4 => 1.9.4 
    vite: ^2.6.14 => 2.6.14 
    vue: ^3.2.22 => 3.2.22 
    vue-i18n: ^9.2.2 => 9.2.2 
    vue-tsc: ^0.29.5 => 0.29.5 

Screenshot

No response

Additional context

No response

Validations

yannbriancon avatar Aug 17 '22 16:08 yannbriancon

related #1113 #1025

The essential improvement is to use conditional exports or the volar plugin.

kazupon avatar Aug 19 '22 11:08 kazupon