Skip to content

Using a store with an action or transition directive does not count as used #877

@geoffrich

Description

@geoffrich

Describe the bug
If I use the value of a store in an action or transition directive using the $ shorthand, VSCode still thinks the store variable is unused.

To Reproduce
Try creating a Svelte component with the following code snippet:

<script>
	import { fly } from 'svelte/transition';
	import { readable } from 'svelte/store';

	const transitionStore = new readable(fly);
	const actionStore = new readable((node) => {
		console.log(node);
	});
</script>

<div transition:$transitionStore={{ y: 100 }} use:$actionStore>
	I'm some content
</div>

Both stores are marked as unused despite being used in the directives (see screenshots below).

If the stores are in the same file as the component, this is only a mild annoyance. However, if they are imported from a different file, the imports are removed when you run "Organize imports" since VSCode thinks they aren't used.

Expected behavior
Using a store value means the store variable is not marked unused.

Screenshots
image

System (please complete the following information):

  • OS: Windows 10 (WSL 2 with the Ubuntu distro)
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions