Skip to content

Commit

Permalink
Fix ts error for slots
Browse files Browse the repository at this point in the history
With @vue/language-tools 2.2.0 `$slots` and `useSlots()` have gotten
better ts support. Sadly this introduced a circular type-dependency when
using `$slots` within a `v-for`. So we needed a workaround to pass the
typecheck.

see also: vuejs/language-tools#5082

RISDEV-0000
  • Loading branch information
malte-laukoetter committed Jan 2, 2025
1 parent e72671c commit 1fa24c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/components/RisLawPreview.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useElementId } from "@/composables/useElementId"
import { v4 as uuidV4 } from "uuid"
import { nextTick, ref, SetupContext, useAttrs, watch } from "vue"
import { nextTick, ref, SetupContext, useAttrs, useSlots, watch } from "vue"
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -373,6 +373,9 @@ watch(
focusedEl.value = interactiveEls.findIndex((i) => i.dataset.eid === val[0])
},
)
// workaround for https://github.com/vuejs/language-tools/issues/5082
const slots: SetupContext["slots"] = useSlots()
</script>

<template>
Expand All @@ -398,7 +401,7 @@ watch(
<!-- eslint-enable vuejs-accessibility/no-static-element-interactions -->

<template
v-for="eId in getTeleportSlotEIds($slots)"
v-for="eId in getTeleportSlotEIds(slots)"
:key="`${uniqueId}-${eId}`"
>
<Teleport v-if="getTeleportTarget(eId)" :to="getTeleportTarget(eId)">
Expand Down

0 comments on commit 1fa24c2

Please sign in to comment.