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: use local variables in v-bind shorthand #4017

Merged
merged 4 commits into from Mar 6, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/language-core/lib/generators/template.ts
Expand Up @@ -1290,7 +1290,10 @@ export function* generate(
const propVariableName = camelize(prop.exp.loc.source);

if (validTsVarReg.test(propVariableName)) {
yield _ts('__VLS_ctx.');
if (!localVars.has(propVariableName)) {
accessedGlobalVariables.add(propVariableName);
yield _ts('__VLS_ctx.');
}
yield* generateCamelized(
prop.exp.loc.source,
prop.exp.loc.start.offset,
Expand All @@ -1314,7 +1317,6 @@ export function* generate(
})
]);
}
accessedGlobalVariables.add(propVariableName);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions test-workspace/tsc/vue3/#3997/main.vue
@@ -0,0 +1,9 @@
<script setup lang="ts">
import { ref } from 'vue';
const values = ref([1, 2, 3]);
</script>

<template>
<input v-for="value of values" :key="value" type="number" :value />
</template>