From 6cc2bd6f2a7c14784af062ceb1482ed602a7a540 Mon Sep 17 00:00:00 2001
From: zhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com>
Date: Sat, 20 Jul 2024 19:04:15 +0800
Subject: [PATCH] fix(language-core): add type check for v-model without
argument (#4598)
---
.../lib/codegen/template/elementProps.ts | 7 ++++++-
test-workspace/tsc/vue2/tsconfig.json | 1 +
test-workspace/tsc/vue3/#4540/component.vue | 5 +++++
test-workspace/tsc/vue3/#4540/main.vue | 13 +++++++++++++
4 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 test-workspace/tsc/vue3/#4540/component.vue
create mode 100644 test-workspace/tsc/vue3/#4540/main.vue
diff --git a/packages/language-core/lib/codegen/template/elementProps.ts b/packages/language-core/lib/codegen/template/elementProps.ts
index dcbd5a9102..7bbb49dbcc 100644
--- a/packages/language-core/lib/codegen/template/elementProps.ts
+++ b/packages/language-core/lib/codegen/template/elementProps.ts
@@ -132,7 +132,12 @@ export function* generateElementProps(
(prop.loc as any).name_2 ?? ((prop.loc as any).name_2 = {}),
shouldCamelize
)
- : [propName]
+ : wrapWith(
+ prop.loc.start.offset,
+ prop.loc.start.offset + 'v-model'.length,
+ ctx.codeFeatures.verification,
+ propName
+ )
),
`: (`,
...genereatePropExp(
diff --git a/test-workspace/tsc/vue2/tsconfig.json b/test-workspace/tsc/vue2/tsconfig.json
index 3363c6cf0b..9aaa7ba292 100644
--- a/test-workspace/tsc/vue2/tsconfig.json
+++ b/test-workspace/tsc/vue2/tsconfig.json
@@ -20,6 +20,7 @@
"../vue3/#3782",
"../vue3/#4327",
"../vue3/#4512",
+ "../vue3/#4540",
"../vue3/components",
"../vue3/defineEmits",
"../vue3/defineModel",
diff --git a/test-workspace/tsc/vue3/#4540/component.vue b/test-workspace/tsc/vue3/#4540/component.vue
new file mode 100644
index 0000000000..ecb17553ea
--- /dev/null
+++ b/test-workspace/tsc/vue3/#4540/component.vue
@@ -0,0 +1,5 @@
+
diff --git a/test-workspace/tsc/vue3/#4540/main.vue b/test-workspace/tsc/vue3/#4540/main.vue
new file mode 100644
index 0000000000..eb2fbb9d39
--- /dev/null
+++ b/test-workspace/tsc/vue3/#4540/main.vue
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+