Skip to content

tm function causes type errors #1686

Open
@ConorMurphy21

Description

@ConorMurphy21

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugBug or Bug fixesgood first issueGood for newcomershelp wantedExtra attention is neededtypescript🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions