Skip to content

defineGeneric NPM Version

Stability: stable

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": ["unplugin-vue-macros/volar"],
  },
}

Contributors

Changelog