Skip to content

Commit

Permalink
fix(language-core): add type check for v-model without argument (#4598)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj authored Jul 20, 2024
1 parent 0213c01 commit 6cc2bd6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/language-core/lib/codegen/template/elementProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions test-workspace/tsc/vue2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"../vue3/#3782",
"../vue3/#4327",
"../vue3/#4512",
"../vue3/#4540",
"../vue3/components",
"../vue3/defineEmits",
"../vue3/defineModel",
Expand Down
5 changes: 5 additions & 0 deletions test-workspace/tsc/vue3/#4540/component.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script setup lang="ts">
defineProps<{ foo: number; }>();
defineModel<number>({ required: true });
</script>
13 changes: 13 additions & 0 deletions test-workspace/tsc/vue3/#4540/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { ref } from 'vue';
import Comp from './component.vue';
const model = ref('');
</script>

<template>
<!-- @vue-expect-error -->
<Comp v-model="model" :foo="1" />
<!-- @vue-expect-error -->
<Comp v-model:model-value="model" :foo="1" />
</template>

0 comments on commit 6cc2bd6

Please sign in to comment.