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

fix(language-core): add type check for v-model without argument #4598

Merged
merged 5 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading