Skip to content

Commit

Permalink
fix: use local variables in v-bind shorthand (#4017)
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve committed Mar 6, 2024
1 parent a444736 commit b54491d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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>

0 comments on commit b54491d

Please sign in to comment.