Vue · props

VUE0031Do not give required props a default

Flags props declared as required that also define a default value.

Why it happens

Parents that omit a required prop get a type error with type-based props and Vue's "Missing required prop" warning in development, yet the default still fills the value at runtime, so the declared contract and the actual behavior disagree.

Fix

Make the prop optional when the default is the intended fallback, or remove the default when every parent must pass the prop.

Example

Make defaulted props optional

Before

<script setup lang="ts">
const props = withDefaults(defineProps<{ size: string }>(), {
  size: 'md',
})
</script>

After

<script setup lang="ts">
const props = withDefaults(defineProps<{ size?: string }>(), {
  size: 'md',
})
</script>

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vue --rules vue/props/no-required-prop-with-default
Copyright © 2026