Generics - Typescript
Generic type parameters can be declared using the
generic
attribute on the <script>
tag:
<script setup lang="ts" generic="T">
defineProps<{
items: T[]
selected: T
}>()
</script>
<script
setup
lang="ts"
generic="T extends string | number, U extends Item"
>
import type { Item } from './types'
defineProps<{
id: T
list: U[]
}>()
</script>