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

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


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 setup lang="ts"></script>

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

And when using it in another component:
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.

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

Copy link

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
bug Something isn't working
None yet

No branches or pull requests

4 participants