Skip to content

Commit 592264c

Browse files
committed
fix(language-core): property access is incorrectly identified as compound expression
close #4600
1 parent 917a676 commit 592264c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/language-core/lib/codegen/template/elementEvents.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export function isCompoundExpression(ts: typeof import('typescript'), ast: ts.So
196196
if (ts.isArrowFunction(child_2)) {
197197
result = false;
198198
}
199-
else if (ts.isIdentifier(child_2)) {
199+
else if (isPropertyAccessOrId(ts, child_2)) {
200200
result = false;
201201
}
202202
});
@@ -208,3 +208,13 @@ export function isCompoundExpression(ts: typeof import('typescript'), ast: ts.So
208208
}
209209
return result;
210210
}
211+
212+
function isPropertyAccessOrId(ts: typeof import('typescript'), node: ts.Node): boolean {
213+
if (ts.isIdentifier(node)) {
214+
return true;
215+
}
216+
if (ts.isPropertyAccessExpression(node)) {
217+
return isPropertyAccessOrId(ts, node.expression);
218+
}
219+
return false;
220+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<!-- @vue-expect-error -->
3+
<button @click="a.b"></button>
4+
<!-- @vue-expect-error -->
5+
<button @click="a.c.d"></button>
6+
</template>
7+
8+
<script lang="ts" setup>
9+
const a = {
10+
b(_msg: string) { },
11+
c: {
12+
d(_msg: string) { }
13+
},
14+
}
15+
</script>

0 commit comments

Comments
 (0)