diff --git a/packages/language-core/lib/parsers/scriptSetupRanges.ts b/packages/language-core/lib/parsers/scriptSetupRanges.ts index 433674d2f1..a95ab04f0a 100644 --- a/packages/language-core/lib/parsers/scriptSetupRanges.ts +++ b/packages/language-core/lib/parsers/scriptSetupRanges.ts @@ -306,11 +306,14 @@ export function parseScriptSetupRanges( if (ts.isVariableDeclaration(parent)) { emits.name = getNodeText(ts, parent.name, ast); } - if (node.typeArguments?.length && ts.isTypeLiteralNode(node.typeArguments[0]) && node.typeArguments[0].members.at(0)) { + if (node.typeArguments?.length && ts.isTypeLiteralNode(node.typeArguments[0])) { for (const member of node.typeArguments[0].members) { - if (ts.isCallSignatureDeclaration(member) && member.parameters[0].type && ts.isUnionTypeNode(member.parameters[0].type)) { - emits.define.hasUnionTypeArg = true; - return; + if (ts.isCallSignatureDeclaration(member)) { + const type = member.parameters[0]?.type; + if (type && ts.isUnionTypeNode(type)) { + emits.define.hasUnionTypeArg = true; + break; + } } } } @@ -377,7 +380,8 @@ export function parseScriptSetupRanges( } } } - } else if (vueCompilerOptions.composibles.useTemplateRef.includes(callText) && node.arguments.length && !node.typeArguments?.length) { + } + else if (vueCompilerOptions.composibles.useTemplateRef.includes(callText) && node.arguments.length && !node.typeArguments?.length) { const define = parseDefineFunction(node); let name; if (ts.isVariableDeclaration(parent)) { diff --git a/test-workspace/tsc/passedFixtures/vue3/#5027/main.vue b/test-workspace/tsc/passedFixtures/vue3/#5027/main.vue new file mode 100644 index 0000000000..c0afbc8e68 --- /dev/null +++ b/test-workspace/tsc/passedFixtures/vue3/#5027/main.vue @@ -0,0 +1,4 @@ + \ No newline at end of file