-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Dynamic slot name Template error: Type 'QTableSlots' has no matching index signature for type 'string'.ts-plugin(2537) #4668
Labels
Comments
davidmatter
added
bug
Something isn't working
🔨 p3-minor-bug
and removed
pending triage
labels
Aug 8, 2024
Regression from #4478 Test case
<template>
<Child>
<template #[`action${n}`]="data">
{{ exactType(data.a, {} as string) }}
</template>
<template #[`action2`]="data">
{{ exactType(data.a, {} as string) }}
</template>
</Child>
</template>
<script lang="ts" setup>
import { exactType } from 'tsc/shared'
import Child from './child.vue'
const n = 1 as const
</script>
<template></template>
<script lang="ts" setup>
defineSlots<{
action1: (props: { a: string }) => void
action2: (props: { a: string }) => void
}>()
</script> |
That worked for me. function getSlotName(name: string): `body-cell-${string}` {
return `body-cell-${name}` as unknown as `body-cell-${string}`;
} |
This can be simplified to: function getSlotName(name: string) {
return `body-cell-${name}` as const;
} |
This works fine! Thanks! |
After 2.1.0 release this is now fixed. No need for the workaround above anymore.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vue - Official extension or vue-tsc version
2.0.28
VSCode version
1.91.1
Vue version
3.4.29
TypeScript version
5.4.5
System Info
No response
Steps to reproduce
As of version 2.0.28 of Vue Official, we get the following syntax highlighting if we use a dynamic slot name. In this case it is for QTableSlots of the Quasar Component Library.
What is expected?
No syntax highlighting as described in https://vuejs.org/guide/components/slots.html#dynamic-slot-names
What is actually happening?
Syntax highlighting and error in Problems window. When using Vue Official 2.0.26 this error does not occur.
Link to minimal reproduction
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: