Skip to content

defineProps sets a default value for a optional prop when using Generics in the props type #13719

@AleTheTwin

Description

@AleTheTwin

Vue version

3.5.18

Link to minimal reproduction

https://play.vuejs.org/#eNp9kdFLwzAQxv+VkCeF0SFTkJlVVPYwH3ToHgNS21vNTJOQXGuh9n/30rI5Qdan3n1fvvzu0vE755KmBj7nAqFyOkNIpZEoCtWkXYcQsO/FNFbSiOmRR4TcK4csANaO6cyUC8kxSE4atM56ZMog+G2WA9tQzmpfiU3KunhJTL+dsw37ZrUpYKsMFDfS9KSZ3JqAzHnrAluwUVzHSvzNerdWQ2aOI9L07JxixHQkJB4+ITJK3Koy2QVraFwCYEzy3FZOafDPDhXdKPk8ojH6JM+0tl+PQw99DZN9P/+A/POf/i60sSf52kMA34DkBw0zXwKO8vL1CVr6P4iVLWpN7hPiCwSr68g42u5pWsI+8g20qyouXplyE5Ytggn7oSJodPaDX3J684cTo//izpLL4Rw9C23xrQEfM2mBs+Qqubjm/Q/UkcSH

Steps to reproduce

To reproduce this bug you need to define a type with generics, one of the props will be optional or the generic type.
in the componente, use defineProps<GenericInterface>.
if the generic is using boolean as the generic type, the defineProps macro will set the attribute to false instead of leaving it as undefined

What is expected?

The prop should have an undefined value.

What is actually happening?

The prop is set to false

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M2
    Memory: 125.22 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.0 - ~/.nvm/versions/node/v22.17.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.17.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.17.0/bin/npm
  Browsers:
    Chrome: 138.0.7204.169
    Safari: 18.5
  npmPackages:
    vue: ^3.5.18 => 3.5.18

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions