-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Labels
Description
Vue version
3.5.5
Link to minimal reproduction
Steps to reproduce
create new project
// App.vue
<script setup lang="ts">
const { test } = withDefaults(defineProps<{
test?: string
}>(), {
test: 'test'
})
</script>
throw error:
error during build:
[vite:vue] [@vue/compiler-sfc] withDefaults() is unnecessary when using destructure with defineProps().
Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).
D:/temp/vite/src/App.vue
1 | <script setup lang="ts">
2 | const { test } = withDefaults(defineProps<{
| ^^^^^^^^^^^^
3 | test?: string
4 | }>(), {
What is expected?
It should not throw an error and shoule not break build, just keep it warning,
Or, if withDefaults
not marked as deprecated
, it should work without any warn or error messages
What is actually happening?
It breaks build
System Info
No response
Any additional comments?
No response