Skip to content

DefineGeneric NPM Version

Stability: experimental ⚠️ Experimental feature, use at your risk

Declare single generic one by one using DefineGeneric.

Especially useful for 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 Configuration

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

Contributors

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

Changelog