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

Slot properties using v-slot are not recognized in recent versions #2554

Closed
weilbith opened this issue Mar 29, 2023 · 3 comments
Closed

Slot properties using v-slot are not recognized in recent versions #2554

weilbith opened this issue Mar 29, 2023 · 3 comments
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@weilbith
Copy link

weilbith commented Mar 29, 2023

Hey folks 👋🏾

I just tried to update the vue-tsc package to something >=1.2.1 to get support for generic components. Unfortunately this comes with a new issue I'm unable to resolve. The following two SFCs demonstrate the problem:

ParentWithSlot.vue

<template>
  <div>
    <slot :foo="1" />
  </div>
</template>

ChildUsingSlot.vue

<script lang="ts" setup>
import ParentWithSlot from "./ParentWithSlot.vue"
</script>

<template>
  <ParentWithSlot v-slot="{ foo }">
     The value of foo is: {{ foo }}
  </ParentWithSlot>
</template>

This tells me in the usage of {{ foo }} that:

Property 'foo' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> &      │
│Omit<Readonly<ExtractPropTypes<{}>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10    │
│more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ?  │
│(args_0: R, args_1: R) => ...'. [2339]                                                                             

This definitely worked in the past. And according to the docs that's how it is supposed to work.

Note that is using a template with a scope name works fine:

ChildUsingSlot.vue

<script lang="ts" setup>
import ParentWithSlot from "./ParentWithSlot.vue"
</script>

<template>
  <ParentWithSlot>
    <template #default="{ foo }">
      The value of foo is: {{ foo }}
    </template>
  </ParentWithSlot>
</template>

While this fix is okay as trade-off for generic components, I would be happy to resolve that issue. Thank you very much for any help!

EDIT:
Using volar as language server at version 1.3.8, there is no auto-completion nor hover functionality for the slot properties also for using the working <template #default="{ foo, bar }"> syntax. Though I can see the references for the slot usages. 🤷🏾

weilbith added a commit to digitalservicebund/ris-backend-service that referenced this issue Mar 29, 2023
The Vue TypeScript compiler package supports in more recent versions
generic Vue components. This is a very powerful feature we are highly
interested in. The latest stable version is `1.2.0`. Though the patch
version `1.2.1` was necessary to overcome some issues. The next version
`1.3.8` is still too experimental, though it would work fine for us.

Updating the compiler came with two issues. First of all this "finally"
discovered our issue with the usage of `aria-label` as custom property
for many input components. Many colleagues have realized this issue in
their development environments earlier. After all that isn't a technical
issue, but requires to unmark this as a HTML exclusive property. The
default for `htmlAttributes` is `['aria-*']`. Therefore an empty list
`[]`, fixes this.
The second issue was with some changes to default slot properties. For
unknown reasons, this requires also the usage of template elements as
for named slots. An issue (vuejs/language-tools#2554) has been raised.
HPrinz pushed a commit to digitalservicebund/ris-backend-service that referenced this issue Apr 5, 2023
The Vue TypeScript compiler package supports in more recent versions
generic Vue components. This is a very powerful feature we are highly
interested in. The latest stable version is `1.2.0`. Though the patch
version `1.2.1` was necessary to overcome some issues. The next version
`1.3.8` is still too experimental, though it would work fine for us.

Updating the compiler came with two issues. First of all this "finally"
discovered our issue with the usage of `aria-label` as custom property
for many input components. Many colleagues have realized this issue in
their development environments earlier. After all that isn't a technical
issue, but requires to unmark this as a HTML exclusive property. The
default for `htmlAttributes` is `['aria-*']`. Therefore an empty list
`[]`, fixes this.
The second issue was with some changes to default slot properties. For
unknown reasons, this requires also the usage of template elements as
for named slots. An issue (vuejs/language-tools#2554) has been raised.
@unitydynamics
Copy link

As noted, I had to rollback to Volar 1.3.4 to avoid seeing these errors.

@pietdevries94
Copy link

In 1.3.14 I encountered that the scope name workaround did not work

@fabis94
Copy link

fabis94 commented Apr 18, 2023

I encountered the same issue - Volar in VSCode seems fine but running vue-tsc for linting returns errors about slot properties not existing. Downgrading vue-tsc to 1.3.4 resolved the issue for me.

@johnsoncodehk johnsoncodehk added bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

5 participants