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): prevent visiting functional components for parseScriptSetupRanges #5049

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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 @@ -400,6 +400,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>
Loading