Subscribe on changes!

Type error when binding props with a slot defined with defineSlots

avatar
Sep 18th 2023

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#eNqNUsFu2zAM/RVBpxZorEN3yhyj29DDdtiKNUddPJt11UmUIFFphiD/PkppUy/bivpkko98j4/ayQ8hNJsMcilbAhdsT9BpFPy1yXoSy01vM6y0JEikZdeqkmZIq2Z4DtMQTSBhe5wKOmkpElAOYgKEaAZOrrlf4+AxkQjRhyRWYoQ7g3BTonYnCslSrMW+Ozt/Rha+F+RtiRjJUZ8tg8/qpKXYiaq0dp+LVSd6/FXnvC9aD+o6eSGNCz7SwvWheUgeefFd2Vc/FVg3zzo4oCU7U2It74mYRKlhRG4bwZpNbBBIYXDqimEqZiTjYDF6d3XZXDbv1GgSzdMNJLf4Ef1jgshDtLyY0ShObiAuIuAIEeJbaU/a5tQnpb/oC/te455NocRe35npxJLBu2AsxG+BDN/iD2t6a/3jl5qjmOG4y3APw89/5B/S9rDTTYSqbLY/9XECfl2lfH37Fbb8fyw6P2b7dIb/FL9D8jYXjQfYx4wjy57hqtrP9cIGp3W63hJgel6qCK1uVHy9x6dXVn+Ry24fXdz/BtB6HGo=

Steps to reproduce

Try to bind a prop to a typed slot

<template>
    <slot :value="test"></slot>
</template>

<script lang="ts" setup generic="T">
const props = defineProps<{ test: T }>()
const slots = defineSlots<{ default: (props: { value: T }) => any }>();
</script>

What is expected?

Test should have the type T

What is actually happening?

Type is incompatible with the slot argument

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 11.72 GB / 31.92 GB
  Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 6.19.1 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Chrome: 117.0.5938.88
    Edge: Spartan (44.22621.2283.0), Chromium (117.0.2045.31)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vue: ^3.0.0 => 3.3.4

Any additional comments?

No response

avatar
Sep 30th 2023