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

Typing of i18n.global.locale #1666

Open
5 tasks done
mberrg opened this issue Mar 22, 2023 · 1 comment
Open
5 tasks done

Typing of i18n.global.locale #1666

mberrg opened this issue Mar 22, 2023 · 1 comment
Labels
Status: Review Needed Request for review comments

Comments

@mberrg
Copy link

mberrg commented Mar 22, 2023

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

@mberrg mberrg added the Status: Review Needed Request for review comments label Mar 22, 2023
@uulingo
Copy link

uulingo commented Mar 27, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

2 participants