Skip to content

defineGeneric NPM Version

稳定性: 稳定

使用 DefineGeneric 逐个声明单个范型。

对于 setup-sfc 特别有用。

FeaturesSupported
Volar Plugin

基本用法

vue
<script setup lang="ts"> 
defineOptions
({
name
: 'App',
}) type
T
=
DefineGeneric
<number>
defineProps
<{
foo
:
T
}>() </script> <template> <
App
foo="1" />
Type 'string' is not assignable to type 'number'.
</template>

Volar 配置

tsconfig.json
jsonc
{  "vueCompilerOptions": {  "plugins": ["unplugin-vue-macros/volar"],  }, }

贡献者

页面历史