Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svelte-language-server thinks it's error to use store value as array index #407

Closed
egormalyutin opened this issue Aug 1, 2020 · 0 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@egormalyutin
Copy link

egormalyutin commented Aug 1, 2020

Describe the bug
I have a component like this:

<script lang="ts">
  import Bar from "./Bar.svelte";
  import { writable } from "svelte/store";

  const currentTab = writable(0);
  const barIcons = ["telescope", "results", "results"];

  import Inputs from "./Inputs.svelte";
  const tabs = [Inputs];
</script>

<main>
  <Bar bind:current={$currentTab} icons={barIcons} />
  <svelte:component this={tabs[$currentTab]} />
</main>

svelte-language-server detects a TypeScript error in <svelte:component this={tabs[$currentTab]} />:

Cannot find name '$currentTab'. Did you mean 'currentTab'?

Although it compiles without any errors or warnings.

What's interesting, if I add "+ 0" or even "+" near $currentTab, svelte-language-server will detect no error.

  <svelte:component this={tabs[+$currentTab]} />

Expected behavior
No errors must be detected.

System (please complete the following information):

  • OS: Arch Linux
  • IDE: nvim with coc-svelte
@egormalyutin egormalyutin added the bug Something isn't working label Aug 1, 2020
@jasonlyu123 jasonlyu123 added the Fixed Fixed in master branch. Pending production release. label Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants