vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Invalid number of arguments, expected 1

Open long2ice opened this issue 2 years ago • 12 comments
trafficstars

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)

long2ice avatar Apr 04 '23 02:04 long2ice

The same problem

CleanShot 2023-04-06 at 18 04 45

dacoto avatar Apr 06 '23 16:04 dacoto

I also face the same lint problem in WebStorm editor

vasilistotskas avatar Apr 17 '23 00:04 vasilistotskas

+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.

priiduneemre avatar Apr 18 '23 09:04 priiduneemre

same here (PHPStorm)

hieblmedia avatar Apr 18 '23 10:04 hieblmedia

Same problem with WebStorm

xxxKOTxxx avatar Apr 18 '23 18:04 xxxKOTxxx

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

lovue avatar May 15 '23 06:05 lovue

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?

kazupon avatar Jun 02 '23 11:06 kazupon

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.

dacoto avatar Jun 02 '23 11:06 dacoto

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...

kazupon avatar Jun 05 '23 06:06 kazupon

Same problem in Intelij

anotherroot avatar Jun 23 '23 10:06 anotherroot

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

rizhenkov avatar Jul 28 '23 12:07 rizhenkov

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.

tspoke avatar Nov 21 '23 13:11 tspoke