-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Description
Vue version
3.3.4
Link to minimal reproduction
Steps to reproduce
- Notice how the
withDefaults
incorrectly assignedvalue: ""
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. removingprops.
) in the template will make a compilation error because it now uses the definition ofdefineProps
instead of the generated on thatwithDefaults
makes for theprops
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
jonasclement, sadeghbarati and OrlS15