kazupon / vue-i18n

:globe_with_meridians: Internationalization plugin for Vue.js

Home Page:https://kazupon.github.io/vue-i18n/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typing of i18n.global.locale

mberrg opened this issue · comments

commented

Reporting a bug?

I'm using vue-i18n 9.2.2, and the typing of 18n.global.locale is string, but is should be ComputedRef<string>?

My setup:

  const i18n = createI18n<[GlobalMessageSchema], SupportedLangs>({
    legacy: false,
    locale: defaultLang,
    fallbackLocale: 'en',
    messages,
  });
  console.log(i18n.global.locale);

Typing reported in VS-code of i18n.global.locale:
ts (property) VueI18n<{}, {}, {}, string, never, string, Composer<{}, {}, {}, string, never, string>>.locale: string

However the variable is clearly a computed ref (from console log):

ComputedRefImpl {dep: undefined, __v_isRef: true, __v_isReadonly: false, _dirty: true, _setter: ƒ, …}

Expected behavior

Typing of i18n.global.locale (and posisble others) should be a computed ref e.g.

(property) VueI18n<{}, {}, {}, string, never, string, Composer<{}, {}, {}, string, never, string>>.locale: ComputedRef<string>

Reproduction

See intro text

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 17.68 GB / 31.70 GB
  Binaries:
    Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1413.0), Chromium (111.0.1661.41)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vitejs/plugin-vue: ^4.1.0 => 4.1.0
    vite: ^4.2.0 => 4.2.0
    vite-plugin-eslint: ^1.8.1 => 1.8.1
    vite-tsconfig-paths: ^4.0.7 => 4.0.7
    vue: ^3.0.0 => 3.2.47
    vue-gtag: ^2.0.1 => 2.0.1
    vue-i18n: ^9.2.2 => 9.2.2
    vue-router: ^4.0.0 => 4.1.6

Screenshot

No response

Additional context

No response

Validations

Cannot set locale via i18n.global.locale.value = locale, Typescript prompts me that locale is a String, Bad !! @mberrg