intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.01k stars 320 forks source link

Invalid number of arguments, expected 1 #1364

Open long2ice opened 1 year ago

long2ice commented 1 year ago

Reporting a bug?

When I use $d and $t, the ts error occur.

image image

Expected behavior

Should no error

Reproduction

Just use it with params

System Info

System:
    OS: macOS 13.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9900KF CPU @ 3.60GHz
    Memory: 14.41 GB / 48.00 GB
    Shell: 3.6.0 - /usr/local/bin/fish
  Binaries:
    Node: 19.8.1 - ~/Library/Caches/fnm_multishells/11823_1680573671866/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.1 - ~/Library/Caches/fnm_multishells/11823_1680573671866/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Safari: 16.5
  npmPackages:
    @vitejs/plugin-vue: ^4.0.0 => 4.1.0 
    @vitejs/plugin-vue-jsx: ^3.0.0 => 3.0.1 
    @vue/eslint-config-prettier: ^7.1.0 => 7.1.0 
    @vue/eslint-config-typescript: ^11.0.2 => 11.0.2 
    @vue/test-utils: ^2.3.0 => 2.3.2 
    @vue/tsconfig: ^0.1.3 => 0.1.3 
    vite: ^4.1.4 => 4.2.1 
    vitest: ^0.29.1 => 0.29.8 
    vue: ^3.2.47 => 3.2.47 
    vue-i18n: ^9.2.2 => 9.2.2 
    vue-router: ^4.1.6 => 4.1.6 
    vue-tsc: ^1.2.0 => 1.2.0 
    vue3-toastify: ^0.1.6 => 0.1.6 


### Screenshot

_No response_

### Additional context

_No response_

### Validations

- [X] Read the [Contributing Guidelines](https://github.com/intlify/vue-i18n-next/blob/master/.github/CONTRIBUTING.md)
- [X] Read the [Documentation](https://vue-i18n.intlify.dev/)
- [X] Check that there isn't [already an issue](https://github.com/intlify/vue-i18n-next/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussions](https://github.com/intlify/vue-i18n-next/discussions)
dacoto97 commented 1 year ago

The same problem

CleanShot 2023-04-06 at 18 04 45

vasilistotskas commented 1 year ago

I also face the same lint problem in WebStorm editor

priiduneemre commented 1 year ago

+1, same issue with JetBrains products.

Wonder if its something that can/should be improved by refined typing or it must be fixed on the IDE side.

hieblmedia commented 1 year ago

same here (PHPStorm)

xxxKOTxxx commented 1 year ago

Same problem with WebStorm

lovue commented 1 year ago

Can add below before the first $t type definition in vue-i18n.d.ts.

$t<
  Key extends string,
  DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  Keys = IsEmptyObject<DefinedLocaleMessage> extends false
    ? PickupPaths<{
      [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
    }>
    : never,
  ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
>(
  key: Key | ResourceKeys | Path,
  named?: Record<string, unknown>
): TranslateResult
kazupon commented 1 year ago

Thank you for your reporting! Sorry for my late reply. šŸ™‡ Unfortunately, I could not reproduce this issue. We need minimal reproduction, so Could you give us your it please?

dacoto97 commented 1 year ago

Thank you for your reporting! Sorry for my late reply. šŸ™‡ Unfortunately, I could not reproduce this issue. We need minimal reproduction, so Could you give us your it please?

In which editor? We have the problem in phpstorm or webstorm with the latest stable version.

kazupon commented 1 year ago

I use always vscode (sometime vim). I would like to check other editors if I could, but unfortunately I don't have time to check all editors. wish there was something like stackbliz that we could check online...

anotherroot commented 1 year ago

Same problem in Intelij

rizhenkov commented 11 months ago

Same problem in PHPStorm 2023.1.4 It's annoying that Storm highlights this as a critical error

image
tspoke commented 7 months ago

Same in Webstorm (#WS-232.10227.9, built on November 11, 2023).

Editing the .d.ts, moving the simplest definition of the method $d() below other $d() definitions fix the issue for multiples args but create the same issue for single arg. Same for others methods ($t,...) . My guess is that Webstorm is not checking other definitions for a method, it only takes the first one it found and mark as invalid if the signature does not match.

I only encounter this behaviour with vue-i18n (since many months now), I never got this kind of errors with other libs among many projects.