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

Custom Directives binding value type is any, but must have 1 argument? #1040

Closed
VisionYi opened this issue Mar 14, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@VisionYi
Copy link

VisionYi commented Mar 14, 2022

Error Message

This error message means Expected 1 argument but got 0 arguments.

image

Custom Directives source code

image

<script setup lang="ts">
import type { Directive } from 'vue'
import { event as gaEvent } from 'vue-gtag'

const vGaClick: Directive<HTMLElement> = {
  mounted(el, binding) {
    const clickCallback = () => {
      gaEvent(binding.arg || 'click', binding.value || {})
    }
    el.addEventListener('click', clickCallback)
  },
}
</script>

Expected Behavior

The binding value default type is any in the custom directive.
I think custom directive needs an argument, this behavior is unnecessary.

Note: I use Vite + Vue3 + TypeScript to develop my application and use VSCode and Volar as IDE.

Other info

This is my devDependencies info of package.json.

image

Versions in the repro cases:
Vue: 3.2.31
vue-tsc / volar: 0.33.1

@VisionYi VisionYi changed the title Custom Directives binding value is any type, but must have a argument? Custom Directives binding value is any type, but must have 1 argument? Mar 14, 2022
@VisionYi VisionYi changed the title Custom Directives binding value is any type, but must have 1 argument? Custom Directives binding value type is any, but must have 1 argument? Mar 14, 2022
@johnsoncodehk johnsoncodehk added the bug Something isn't working label Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants