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

v-slot: This expression is not callable. Type XXX has no call signatures. #3117

Open
Jungzl opened this issue May 4, 2023 · 2 comments
Open

Comments

@Jungzl
Copy link

Jungzl commented May 4, 2023

Description

<script lang="ts" setup>
import { ref } from 'vue';

const foo = ref('bar');

defineSlots<{
  default: {
    foo: string;
  };
}>();
</script>

<template>
  <div>
    <slot v-bind="{ foo }" />
    <!-- ^^^  This expression is not callable. 
              Type '{ foo: string; }' has no call signatures. -->
  </div>
</template>

Reproduction

Stackblitz

@johnsoncodehk
Copy link
Member

johnsoncodehk commented May 4, 2023

This is expected, see #3116.

You need to change the code to

defineSlots<{
  default: {
-    foo: string;
+    foo?: (_: string) => any;
  };
}>();

@jd-solanki
Copy link
Contributor

jd-solanki commented May 7, 2023

Hey Johnson,

I just noticed short slots syntax is not supported ATM. I wanted to point out that I was using object syntax and generating type based on that using defineSlots<typeof aTableSlots>().

For complex component like select which uses list and list-item under the hood, I modify the obj according to user DX and implementation and later generate type using defineSlots<typeof aSelectSlots>.

So the point I'm trying to make is, using object syntax was fairly easy and it was easy to modify and extend the slots objects. (e.g. prefixObjectKeys(listSlots, 'list-item-') for reusing slots in another component)

However, with full syntax, it's hard to modify the slots as value because now we have to deal with function params instead of object.

So, here's my use case and request for bringing back object syntax.

Thanks for your efforts 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants