Skip to content

defineProps

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

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

Contributors

The avatar of contributor named as renovate[bot] renovate[bot]
The avatar of contributor named as zhiyuanzmj zhiyuanzmj
The avatar of contributor named as Kevin Deng Kevin Deng

Changelog