# vue/define-props-declaration
enforce declaration style of
defineProps
- ❗️ This rule has not been released yet.
# 📖 Rule Details
This rule enforces defineProps
typing style which you should use type-based
or runtime
declaration.
This rule only works in setup script and lang="ts"
.
<script setup lang="ts">
/* ✓ GOOD */
const props = defineProps<{
kind: string
}>()
/* ✗ BAD */
const props = defineProps({
kind: { type: String }
})
</script>
# 🔧 Options
"vue/define-props-declaration": ["error", "type-based" | "runtime"]
type-based
(default) enforces type-based declarationruntime
enforces runtime declaration
# "runtime"
<script setup lang="ts">
/* ✗ BAD */
const emit = defineEmits<{
(e: 'change', id: number): void
(e: 'update', value: string): void
}>()
/* ✓ GOOD */
const emit = defineEmits(['change', 'update'])
</script>
# 👫 Related Rules
# 📚 Further Reading
defineProps
(opens new window)- Typescript-only-features of
defineProps
(opens new window) - Guide - Typing-component-props (opens new window)