Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defineModel() wrong 'default' type #12145

Open
DrWarpMan opened this issue Oct 10, 2024 · 0 comments · May be fixed by #12158
Open

defineModel() wrong 'default' type #12145

DrWarpMan opened this issue Oct 10, 2024 · 0 comments · May be fixed by #12158

Comments

@DrWarpMan
Copy link

Vue version

3.5.11

Link to minimal reproduction

https://play.vuejs.org/#eNqNk92O0zAQhV9l5Ju2UpQqzS5IoVsJ0F4sEj8C7jBCbjJJUxw7sifdVlXfnXHSAmJpu3fJzJnzHTuTvXjdtvGmQ5GJuc9d3RJ4pK4FrUx1JwV5KRbS1IbQlSpHeCBsYC8NQF1kYLpmie5VeDWqwQw8udpUXDhII02BZW3wvS1Qz8PgYixFaW0iRTR4sEB1mjIYT+BuAeN975pER7dklsJhEsF0CqNQGYFf2U4XsESwJdCuRRgNyBEjJxeYs/NM7mYgxVI5KY603DatRkK9g6IuS3RoCOxyjTld4aRnOd+SaBal3weAck7tPCjtLRQWjCWglbOPJ3eWWFqhAywqhFx59BegN+egptM6upL49txwd5worjm8eOrwHPDLp2P/IufTYSl5BfmFR1utCGG6EBGvZm5NWVfx2lvD+9s7SRE+Xa3RfWyptobXNxsYoae0to/v+hq5Dhky1PMV5j//U1/7bahJ8cmhR7dBTnzqkXIV0tC+//IBt/z8u9nYotOsvtD8jN7qLmQcZG/47Bz7L12f9qFprSNe8K/+fkto/OlQIWhQHnq9FPwTv71w9D9x0/imn+Mb5lv8sUEXPPkC0/g2ThJx+AXqA1d+

Steps to reproduce

In the repro, you can see multiple defineModel() macros, none of them throw a type error, even if the types don't match the Item interface.

e.g.:

interface Item {
  id: number;
  name: string;
}

defineModel<Item>("foo1", {
  default: () => ({ id: 1, name: 123 }), // 'name' should be of type 'string'
})

What is expected?

A type error should be thrown for the defineModel() default values.

What is actually happening?

No type error is shown.

System Info

No response

Any additional comments?

It also behaves kinda strangely with basic types: playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants