Skip to content

Optional props are incorrectly typed in <template> #3779

Closed
@DrJume

Description

@DrJume

Optional props in Vue 3 are not optional anymore on the resolved props value from defineProps:

Additionally, Vue 3 casts optional boolean props to only type boolean, because of https://vuejs.org/guide/components/props.html#boolean-casting.

The only correct way to allow undefined for a boolean prop is to manually set it as a default with withDefaults. (see reproduction components/BooleanWithUndefined.vue)

This should also reflect in the <template>.

Link to reproduction

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood reproduction ✨This issue provides a good reproduction, we will be able to investigate it firstupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions