Skip to content

Commit

Permalink
fix: prevent MemberExpression & VariableDeclarator in $variable
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Nov 7, 2023
1 parent 1f029f3 commit 633fd60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ function transformReactivityFunction(code: string, id: string) {
s.appendRight(node.start! + offset + 1, '(')
s.appendRight(parent.end! + offset, ')')
}
} else if (node.type === 'Identifier') {
} else if (
node.type === 'Identifier' &&
parent?.type !== 'MemberExpression' &&
parent?.type !== 'VariableDeclarator'
) {
s.appendRight(node.start! + offset + 1, '$(')
s.appendRight(node.end! + offset, ')')
}
Expand Down
6 changes: 5 additions & 1 deletion src/volar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ function transform({
')'
)
}
} else if (ts.isIdentifier(node)) {
} else if (
ts.isIdentifier(node) &&
!ts.isPropertyAccessExpression(parent) &&
!ts.isVariableDeclaration(parent)
) {
replaceSourceRange(
codes,
source,
Expand Down

0 comments on commit 633fd60

Please sign in to comment.