tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
482 stars 38 forks source link

Unresolved variable for store when using TypeScript #304

Closed thacoon closed 1 year ago

thacoon commented 2 years ago

When using TypeScript I get an unresolved variable error in WebStorm Screenshot from 2022-08-17 10-47-03

To reproduce this issue, see the following code:

src/routes/test.svelte

<script lang="ts">
    import { count } from '../../store/test';

    $count.count  // here the unresolved variable error is displayed
</script>

<h1>The count is {$count.count}</h1>

<button on:click={count.increment}>+</button>
<button on:click={count.decrement}>-</button>
<button on:click={count.reset}>reset</button>

store/test.ts

import { writable } from 'svelte/store';

interface Data {
    count: number
}

function createCount() {
    const { subscribe, set, update } = writable<Data>({
        count: 0
    });

    return {
        subscribe,
        increment: () => update(n => ({
            count: n.count + 1,
        })),
        decrement: () => update(n => ({
            count: n.count - 1,
        })),
        reset: () => set({count: 0})
    };
}

export const count = createCount();
srsholmes commented 2 years ago

Related to #303

tomblachut commented 1 year ago

Contained in WEB-58397 use the svelte language server.