Skip to content

Commit 22b6058

Browse files
fix: add reassigned check and curlies
Co-authored-by: Simon H <[email protected]>
1 parent 7952bd0 commit 22b6058

File tree

1 file changed

+4
-2
lines changed
  • packages/svelte/src/compiler/phases/2-analyze

1 file changed

+4
-2
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,11 @@ export function analyze_component(root, source, options) {
356356
if (
357357
declaration !== null &&
358358
declaration.kind === 'normal' &&
359-
declaration.declaration_kind === 'let'
360-
)
359+
declaration.declaration_kind === 'let' &&
360+
declaration.reassigned
361+
) {
361362
declaration.kind = 'state';
363+
}
362364

363365
const binding = instance.scope.declare(b.id(name), 'store_sub', 'synthetic');
364366
binding.references = references;

0 commit comments

Comments
 (0)