Skip to content

templateRef NPM Version

稳定性: 实验性 ⚠️ 实验性功能,风险自负

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

对于 setup-sfc 特别有用。

FeaturesSupported
Volar Plugin

Basic Usage

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 配置

jsonc
// tsconfig.json
{
  "vueCompilerOptions": {
    "plugins": [
      "@vue-macros/volar/define-generic",
      // ...more feature
    ],
  },
}

贡献者

The avatar of contributor named as Kevin Deng 三咲智子 Kevin Deng 三咲智子
The avatar of contributor named as zhiyuanzmj zhiyuanzmj

页面历史