-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Invalid assignment target
in v-model data binding with type assertion when building for production
#12620
Comments
It seems related to https://github.com/unjs/unimport. This issue only occurs when the The following code will work as expected. <script setup lang="ts">
+import { ref } from "vue";
const data = ref(1);
</script>
<template>
<div>
<FooBar v-model="data as any" />
</div>
</template>
|
Thanks! I forgot Playground can be run in production mode. It is much easier to reproduce! |
I do some research, I set a breakpoint during And I find this, when When with So, is this should do some fix in |
This is the exact reason for the problem. Vue analyzes the variable types during compilation, if |
Ok, I understand what you mean. Thanks! @edison1105 But there is one thing I don't quite understand: |
Vue version
3.5.13
Link to minimal reproduction
https://stackblitz.com/edit/github-4n1bjaud
Steps to reproduce
v-model
, for example,v-model="foo as any"
npm run build
What is expected?
Project successfully building for production.
What is actually happening?
type assertion is not removed:
System Info
System: OS: Linux 5.0 undefined CPU: (6) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.20.3 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm npmPackages: vue: latest => 3.5.13
Any additional comments?
It works fine in development.
Very similar to #8306
The text was updated successfully, but these errors were encountered: