Vue version
3.3.4
Link to minimal reproduction
https://play.vuejs.org/#eNp9U01v2zAM/SucMMAJ4LiH3jy33VeAFdi6Yit20kWx6USdLAmWlKQI8t9HSXHaYkAvtsRHPz4+0gf2ydpqG5DVrHHtKK0Hhz5YUEKvrzjzjrNrrqX2OPaiRbgfjXVw4BpgMB2qP0IFvKlhZYxCoT9EoJNOrBR2r8JHrrlujXYebOK4gp30m6/Yi6C8m3XYS42JvknP69m8zIW2sUYNvVAOy5cFTjEin1OFiR4H6Yk9Ey7p4ppEM8Mtal8DZ8F2wmP93ABn5VTlpHhew9bILgonIfRqLrI/5AZdPA5WEQfdABqpbfDxBOCfLJJv7Qbbvyuz5yyH6xTAjqDUfZWqndGpoTM8BaaMj+2GBhKZY3ez4r8OihJm71ODlRfjGj0IB98efny/jdqWCgeC5tVJxjzzXiT5h0OeSNYEN1A8oSughkKbAo5HaN4tFnCHu5QGK2xFcAimfzXAElbBw4aqRgvIZE1qRs5gsbiGaN/ZMlbSWtGoermuHp3RtHtpPuSaGaxUOP60XtIoOavzAkTM+VG2Pob8GPIaxPCjI4/jTO9HdDhu4ygnLBuR4eXvO9zT+QySdUFR9hvgL3RGhSglp30OuiN1L/KEUmZ3O1gzeqnXD26596jdpD0KjZnHlM8Z/Wdf3ujwWe5ldZm+o+Vjx38lvTqz
Steps to reproduce
- Notice how the
withDefaults incorrectly assigned value: "" as the default modelValue.
- Observe that TypeScript doesn't complain about adding an unknown property to
withDefaults
- Observe in the template that
props.value is used (and compilation is alright) - but notice the value doesn't change if you toggle the checkbox.
- Using
value (ie. removing props.) in the template will make a compilation error because it now uses the definition of defineProps instead of the generated on that withDefaults makes for the props object.
What is expected?
Compile error when defining a default value in withDefaults for a property that doesn't exists on the interface / defineProps().
What is actually happening?
The value property gets added to the props object with type never.
System Info
No response
Any additional comments?
Ran into this issue in a production app where the modelValue should have had a default value, which incorrectly got set to value: "" - a bit unfortunate that it ended up in production and the state of the checkbox weren't visible. This could have been mitigated if we were warned by typescript that we are trying to add a property that doesn't exist in the Props / on the component
Vue version
3.3.4
Link to minimal reproduction
https://play.vuejs.org/#eNp9U01v2zAM/SucMMAJ4LiH3jy33VeAFdi6Yit20kWx6USdLAmWlKQI8t9HSXHaYkAvtsRHPz4+0gf2ydpqG5DVrHHtKK0Hhz5YUEKvrzjzjrNrrqX2OPaiRbgfjXVw4BpgMB2qP0IFvKlhZYxCoT9EoJNOrBR2r8JHrrlujXYebOK4gp30m6/Yi6C8m3XYS42JvknP69m8zIW2sUYNvVAOy5cFTjEin1OFiR4H6Yk9Ey7p4ppEM8Mtal8DZ8F2wmP93ABn5VTlpHhew9bILgonIfRqLrI/5AZdPA5WEQfdABqpbfDxBOCfLJJv7Qbbvyuz5yyH6xTAjqDUfZWqndGpoTM8BaaMj+2GBhKZY3ez4r8OihJm71ODlRfjGj0IB98efny/jdqWCgeC5tVJxjzzXiT5h0OeSNYEN1A8oSughkKbAo5HaN4tFnCHu5QGK2xFcAimfzXAElbBw4aqRgvIZE1qRs5gsbiGaN/ZMlbSWtGoermuHp3RtHtpPuSaGaxUOP60XtIoOavzAkTM+VG2Pob8GPIaxPCjI4/jTO9HdDhu4ygnLBuR4eXvO9zT+QySdUFR9hvgL3RGhSglp30OuiN1L/KEUmZ3O1gzeqnXD26596jdpD0KjZnHlM8Z/Wdf3ujwWe5ldZm+o+Vjx38lvTqz
Steps to reproduce
withDefaultsincorrectly assignedvalue: ""as the default modelValue.withDefaultsprops.valueis used (and compilation is alright) - but notice the value doesn't change if you toggle the checkbox.value(ie. removingprops.) in the template will make a compilation error because it now uses the definition ofdefinePropsinstead of the generated on thatwithDefaultsmakes for thepropsobject.What is expected?
Compile error when defining a default value in
withDefaultsfor a property that doesn't exists on the interface /defineProps().What is actually happening?
The
valueproperty gets added to thepropsobject with typenever.System Info
No response
Any additional comments?
Ran into this issue in a production app where the modelValue should have had a default value, which incorrectly got set to
value: ""- a bit unfortunate that it ended up in production and the state of the checkbox weren't visible. This could have been mitigated if we were warned by typescript that we are trying to add a property that doesn't exist in the Props / on the component