-
-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.bugSomething isn't workingSomething isn't working
Description
Describe the bug
When writing reactive, destructured declarations (using the $: directive), with certain combinations of renames & default initialisers, TypeScript would be confused into thinking it's a variable assignment expression instead of a declaration statement.
Reproduction
<script lang="ts">
// 1. OK → $: ({ a = 1, c: d = 2 } = { a: 0, c: 0 });
// 2. OK → $: ({ a: b = 1, c: d } = { a: 0, c: 0 });
// 3. OK → $: ({ a: b = 1, c = 2 } = { a: 0, c: 0 });
// 4. OK → $: ({ a: b = 1, c: d, e: f = 2 } = { a: 0, c: 0, e: 0 });
// 5. NOK → $: ({ a: b = 1 } = { a: 0 });
// 6. NOK → $: ({ a: b = 1, c: d = 2 } = { a: 0, c: 0 });
// Using no. 5 as a runnable example that fails:
$: ({ a: b = 1 } = { a: 0 });
// ^ Cannot find name 'b'. ts(2304)
</script>Expected behaviour
<script lang="ts">
// 1. OK → $: ({ a = 1, c: d = 2 } = { a: 0, c: 0 });
// 2. OK → $: ({ a: b = 1, c: d } = { a: 0, c: 0 });
// 3. OK → $: ({ a: b = 1, c = 2 } = { a: 0, c: 0 });
// 4. OK → $: ({ a: b = 1, c: d, e: f = 2 } = { a: 0, c: 0, e: 0 });
// 5. OK → $: ({ a: b = 1 } = { a: 0 });
// 6. OK → $: ({ a: b = 1, c: d = 2 } = { a: 0, c: 0 });
// Using no. 5 as a runnable example that shouldn't fail:
$: ({ a: b = 1 } = { a: 0 });
// ^ let b: number
</script>System Info
- OS: Windows 11 21H2
- IDE: VSCode 1.70.1
Which package is the issue about?
svelte-language-server
Additional Information, eg. Screenshots
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.bugSomething isn't workingSomething isn't working
