vue-i18n
vue-i18n copied to clipboard
Resource Keys completion does not work with global messages and $t
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:
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
- [X] Read the Contributing Guidelines
- [X] Read the Documentation
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion
- [X] The provided reproduction is a minimal reproducible example of the bug.
related #1113 #1025
The essential improvement is to use conditional exports or the volar plugin.