-
-
Notifications
You must be signed in to change notification settings - Fork 444
TypeScript error for @click
- Type '() => void' is not assignable to type 'undefined'
#464
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
Comments
I can't reproduce this problem, please try update your deps. |
Duplicate of #460 |
Thanks, I didn't find #460 before opening this one, should have looked more carefully. Edit: removed to avoid misinformation. |
This is what I get "by default" after running |
Have you try delete package-lock.json / yarn.lock + node_modules and reinstall it? |
Not yet, will give it another try tomorrow and test on another machine too. Will report back with additional info. Thanks! |
Good morning, just deleted node_modules and package-lock.json, reinstalled and Still no idea what broke it, might look into it some more if it ever happens again. Thanks for your time and tips @johnsoncodehk, really appreciate it! |
I found that reinstalling node_modules didn't work for me. Here's something strange I noticed though: I have a custom component that I'm using a |
@vincerubinetti fixed by 94d1546. |
make sure you don't have this extension installed in visual studio code: Vue Language Features (Fly), uninstalling it removed that underline VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=Vue.volar |
This issue appears again on v1.0.3. This version has a few breaking changes e.g. this issue and also kebab-case prop |
Here is a minimal vue component for you to reproduce this problem:
Error:
<script setup lang="ts">
// We can not use <RouterLink> in headlessui:
// - https://github.com/tailwindlabs/headlessui/issues/143
</script>
<template>
<span
@click="
() => {
if (typeof $attrs.href === 'string') {
if ($attrs.mode === 'replace') {
$router.replace($attrs.href)
} else {
$router.push($attrs.href)
}
}
}
"
><a class="cursor-pointer"><slot /></a
></span>
</template> |
I encountered the same problem in the Nuxt3 project. |
Downgrade to types/18.8.0 fixed the issue for me |
yeah, I just solved |
thanks a lot, this resolved this issue for me! |
Sorry newbie here. How do I downgrade this in nuxt 3? |
npm i @types/[email protected] |
This issue will be fixed after we merge: vuejs/core#6855 |
@omarmfs98 your solution is like little kids playing hide and seek: If I cover my eyes, nobody can see me. Apparently the problem is not within Volar, so uninstalling Volar will not make it go away, you will just not see it anymore - like a lot of other useful stuff Volar is showing you. |
Any updates on this? I have updated dependencies and I still see this in my ts errors:
Template: <router-link
v-for="(navigationItem, index) of navigationItems"
:key="index"
v-slot="{ isActive, navigate }"
...>
<div
@click="navigate"
<!-- following line creates the error above -->
@keypress.enter="navigate"> |
Any news on this? I just downgraded to 18.8.0 which solved it for me for now. |
Updated to VS Code 1.60 (TypeScript 4.4) today and started seeing these TS errors in my SFC's:
There were no issues when I worked on the project last week.
Full component: https://github.com/ttntm/recept0r-ts/blob/main/src/views/Home.vue
This TS error happens to any
@click
attributes that are attached to components with props defined via TypeScript (as described here: https://v3.vuejs.org/api/sfc-script-setup.html#typescript-only-features):@click
for components with TS props:(property) click: undefined
@click
for components without TS props:(property) click: ((...args: any[]) => any) | undefined
...copying that type definition into the button component's
defineProps
doesn't make any difference; any type for propertyclick
seems to be ignored.The text was updated successfully, but these errors were encountered: