Skip to content

defineModel has wrong type when used with @update:model-value event #12817

Closed
vuejs/language-tools
#5171
@thomasaull

Description

@thomasaull

Vue version

3.5.13

Link to minimal reproduction

https://play.vuejs.org/#eNqVUslu20AM/RViLpYBQ3I3FHBlo1sOLdAFbXobIFYlSlE6mlFncRy4+veSo1o1iiZBLgKHfKQeH99BvOr7dBdQrETuStv2Hhz60IMqdLOWwjspNlK3XW+shwNYrGGA2poOZtQ2m0pvTNf/yacZP3gqlaXOMthWhccttA6K0odCqRvYvqUU/IKgK6xbjdUWvgcP/hItMlAb8Dc9AlprrNR10KVvjQajv/U8jdsTDlbA4RwOUgOURjujMFWmSWan0NkCOJwzoUHqPBuXpdXo4bHrFVXpBZDHTV6G2LriD8lwOkoKyAiZZ1ObWJBO9Ou6bdIrZzSJGdlIUdKsVqH91DN50nI18uQayWCu38ectwEXx3x5ieWP/+Sv3J5zUny26NDuiMhU84Vt0I/ls68fcU/xVOxMFRSh7yh+QZItMMcR9prOQrRPcJHtu3jrVjfn7mzvUbvjUkyUkUPES0G3ZxlvW/0v3Sfp09hHVyEVj765x418ZQ/EHFV00RpGD33gTM6pTTLjc9HV4z8t/gytxWoFdaEcMR2iEWj2eduhCT5J5rDejOBpbrorVODpGq+jyRLqGhbwbLmcv3hI/+Tx2P7oYjkOuMOE/9rrYoeWxSZhSLH08XMx/AaVXUHO

Steps to reproduce

  • Run the playground
  • Check the console
  • The onUpdateDate method is called twice, the first time with a Date the second time with undefined. The typescript types don’t reflect this behaviour

What is expected?

The types should indicate that the event payload can be Date | undefined

What is actually happening?

The event payload is typed as Date

System Info

Any additional comments?

Types as they show up in my IDE (VS Code):

  • const modelDate: ModelRef<Date | undefined, string, Date | undefined, Date | undefined>
  • (property) "onUpdate:date"?: ((date: Date) => any) | undefined

Please note that the SFC Playground (at least for me) doese not show the types correctly for some reason

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions