Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/long-rabbits-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

Fix error in member expr on LHS of reactive statement with TS
7 changes: 6 additions & 1 deletion src/parser/analyze-type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ function appendDeclareSvelteVarsTypesFromAST(
node.label.name !== "$" ||
parent !== result.ast ||
node.body.type !== "ExpressionStatement" ||
node.body.expression.type !== "AssignmentExpression"
node.body.expression.type !== "AssignmentExpression" ||
(node.body.expression.left.type !== "Identifier" &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend to add some comments here, or at least link the original issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review!
I added comments.

node.body.expression.left.type !== "ArrayPattern" &&
node.body.expression.left.type !== "ObjectPattern" &&
node.body.expression.left.type !== "AssignmentPattern" &&
node.body.expression.left.type !== "RestElement")
) {
return;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/parser/ast/ts-not-reactive01-input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script lang="ts">
const num = 42
const obj:{ foo?: number } = {}
$: obj.foo = num
</script>
{obj.foo}
Loading