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

tm function causes type errors #1686

Open
4 tasks done
ConorMurphy21 opened this issue Jan 8, 2024 · 3 comments
Open
4 tasks done

tm function causes type errors #1686

ConorMurphy21 opened this issue Jan 8, 2024 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage Type: Bug Bug or Bug fixes typescript

Comments

@ConorMurphy21
Copy link

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

@ConorMurphy21 ConorMurphy21 added the Status: Review Needed Request for review comments label Jan 8, 2024
@kazupon kazupon added Type: Bug Bug or Bug fixes good first issue Good for newcomers 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage typescript help wanted Extra attention is needed and removed Status: Review Needed Request for review comments labels Jan 10, 2024 — with Volta.net
@kazupon kazupon mentioned this issue Apr 3, 2024
4 tasks
@TheDutchCoder
Copy link

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)

@shanyi-front
Copy link

l have same problem

@DarkLite1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage Type: Bug Bug or Bug fixes typescript
Projects
None yet
Development

No branches or pull requests

5 participants