Skip to content

Commit

Permalink
fix(language-core): prevent visiting functional components for parseS…
Browse files Browse the repository at this point in the history
…criptSetupRanges (vuejs#5049)
  • Loading branch information
zhiyuanzmj authored Dec 20, 2024
1 parent 209717c commit 526ce74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/language-core/lib/parsers/scriptSetupRanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ export function parseScriptSetupRanges(
}

ts.forEachChild(node, child => {
if (ts.isFunctionLike(node)) {
return;
}
parents.push(node);
visitNode(child, parents);
parents.pop();
Expand Down
11 changes: 10 additions & 1 deletion test-workspace/tsc/passedFixtures/vue3/templateRef/main.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<script setup lang="ts">
import TemplateRef from './template-ref.vue';
import { useTemplateRef } from 'vue';
import { exactType } from '../../shared';
import TemplateRef from './template-ref.vue';
function Comp() {
const foo = useTemplateRef('templateRef');
exactType(foo.value, {} as unknown);
return '';
}
</script>

<template>
<TemplateRef ref="templateRef" />

{{ exactType($refs.templateRef?.$refs.generic?.foo, {} as (1 | undefined)) }}

<Comp />
</template>

0 comments on commit 526ce74

Please sign in to comment.