intlify/vue-i18n

tm function causes type errors

ConorMurphy21 opened this issue · 4 comments

Reporting a bug?

When using vue-18n with typescript I have not found a way to properly type the tm function, following https://vue-i18n.intlify.dev/guide/advanced/typescript.html as guide. See the repro that shows a working use case of using the tm + rt functions. But give the following error when vue-tsc is run error TS2339: Property 'bar' does not exist on type 'number'. {{ rt(test.bar) }}.
See main.ts and App.vue for the i18n impl.

Expected behavior

The example code provided below should pass typechecking.

Reproduction

https://stackblitz.com/edit/vitejs-vite-eac2nt?file=App.vue

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 13.78 GB / 31.93 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.121)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vitejs/plugin-vue: ^4.5.2 => 4.6.2
    @vue/eslint-config-prettier: ^8.0.0 => 8.0.0
    @vue/eslint-config-typescript: ^12.0.0 => 12.0.0
    @vue/tsconfig: ^0.5.0 => 0.5.1
    vite: ^5.0.10 => 5.0.11
    vue: ^3.3.11 => 3.4.5
    vue-i18n: ^9.9.0 => 9.9.0
    vue-router: ^4.2.5 => 4.2.5
    vue-tsc: ^1.8.25 => 1.8.27

Screenshot

No response

Additional context

No response

Validations

Is there a potential that this gets picked up?
It's a pretty annoying problem when working wit TS as people now have to create manual types and cast the tm return value in the template: (item as unknown as MyType)

l have same problem

Same issue. Also reported a reproduction here. Any update on this?