Skip to content

Commit 633fd60

Browse files
committed
fix: prevent MemberExpression & VariableDeclarator in $variable
1 parent 1f029f3 commit 633fd60

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ function transformReactivityFunction(code: string, id: string) {
114114
s.appendRight(node.start! + offset + 1, '(')
115115
s.appendRight(parent.end! + offset, ')')
116116
}
117-
} else if (node.type === 'Identifier') {
117+
} else if (
118+
node.type === 'Identifier' &&
119+
parent?.type !== 'MemberExpression' &&
120+
parent?.type !== 'VariableDeclarator'
121+
) {
118122
s.appendRight(node.start! + offset + 1, '$(')
119123
s.appendRight(node.end! + offset, ')')
120124
}

src/volar.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ function transform({
128128
')'
129129
)
130130
}
131-
} else if (ts.isIdentifier(node)) {
131+
} else if (
132+
ts.isIdentifier(node) &&
133+
!ts.isPropertyAccessExpression(parent) &&
134+
!ts.isVariableDeclaration(parent)
135+
) {
132136
replaceSourceRange(
133137
codes,
134138
source,

0 commit comments

Comments
 (0)