Skip to content

defineProps NPM Version

Stability: stable

Correct types of destructured props using $defineProps.

See also Vue issue, Reactivity Transform RFC.

FeaturesSupported
Vue 3
Nuxt 3
Vue 2
TypeScript / Volar Plugin

WARNING

Reactivity Transform is required. You should enable it first.

Basic Usage

vue
<script setup lang="ts">
const { 
foo
} =
$defineProps
<{
foo
: string[]
}>() const
fooRef
=
$$
(
foo
)
</script>

Volar Configuration

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

Contributors

Changelog