defineGeneric
Stability:
stableDeclare single generic one by one using DefineGeneric.
Especially useful for
setup-sfc.
| Features | Supported |
|---|---|
| Volar Plugin | ✅ |
Basic Usage
vue
<script setup lang="ts">
defineOptions({
name: 'App',
})
type T = DefineGeneric<number>
defineProps<{
foo: T
}>()
</script>
<template>
<App foo="1" /></template>Volar Configuration
jsonc
{
"vueCompilerOptions": {
"plugins": ["vue-macros/volar"],
},
}
Kevin Deng
zhiyuanzmj
Leo