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

Named slot gets ts(7053) error with <script setup> alongside normal <script> #1389

Closed
linfengOu opened this issue Jun 4, 2022 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@linfengOu
Copy link

linfengOu commented Jun 4, 2022

Say I have below component: SlotComponent. It has normal <script> to define inheritAttrs: false. Also I use <script setup>:

<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({ inheritAttrs: false });
</script>

<script setup lang="ts"></script>

<template>
  <slot name="header"></slot>
  <br />
  <slot></slot>
  <br />
  <slot name="footer"></slot>
</template>

And when using it in another component:
image
Named slots get error:

Element implicitly has an 'any' type because expression of type '"header"' can't be used to index type '{} | {}'.
  Property 'header' does not exist on type '{} | {}'.ts(7053)

But as long as I remove <script setup lang="ts"></script>, everything is fine.

Please kindly suggest.

@yangdanping
Copy link

yangdanping commented Jun 4, 2022

Seems to have the same problem.
v-bind & named slot will changes the type of components and attributes to any.
and this problem only seems to occur when setup sugar is used.
GIF 2022-6-4 12-17-23

@AnyaParry
Copy link

image
so, what happend?

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Jun 4, 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

4 participants