Skip to content

defineModel's modifiers type is incompatible with runtime value #9945

@sqal

Description

@sqal

Vue version

3.4

Link to minimal reproduction

https://play.vuejs.org/#__PROD__eNqNUk1PGzEQ/SuWL0mkxFspPaUB0VYcWqkfahEXzGHZnSwGf2k8GyKF/HfGuyQsEUIcVmvPG79579lb+TVGtW5BLuQyVWgiiQTURmFL35xoSUnLU+2FqIJPJK5cqMFelraFqeC1WRnAdC1ORA0r4+FXhpeJ0PhmKkb8dyPxKEZtjIBVmWB0Op580X7PGCwoG5rx9oVM7CY9blZifKiqTDUR2wzkb6f9sugFszzeELhoS4IsNmODvZyyDZ62Mo26S8Gz155HVsFFYwH/RDKsRstFPyFjpbXh4WdXI2S7+3p1C9X9G/W7tMk1Lf8iJMA1aHnAqMQGqIfP//+GDa8PIHtsLXe/A/4DTqrNGvu2b62vWfagr1P7w8WAxNFfpPMNgU97U1lol1rXryVf+Pd3rL/Inav5c9o7TtF0/DNXxqMce+A1Cc/oxd4SxbQoiqr2fIzfh1mj8kCFj64447YCW0/GwawO7myuPqtPRW0SDcsKkpvdYHjgZFXEUDPTwH0m6TLHGYKvAXM2H5t9dGw4/wh6pSGPPySzewKTxRvq

Steps to reproduce

const [modelValue, modifiers] = defineModel<string, 'trim' | 'uppercase'>();

// @ts-expect-error
if (modifiers.trim) {}

What is expected?

modifiers type should be a Record or undefined

What is actually happening?

modifiers type is always a Record, but its runtime value can be undefined. So either fix modifiers type or use an empty object as a fallback?

System Info

No response

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