tomblachut / svelte-intellij

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

$store type is not detected when using default export #266

Closed Bickio closed 1 year ago

Bickio commented 2 years ago

Example store

store.ts

import type { Readable } from 'svelte/store'

export const store: Readable<string> = {
    subscribe(callback) {
        callback('Hello world')
        return () => {
            console.log('unsubscribe')
        }
    }
}

export default store

Note: I used two import types here to reduce code snippets, but the issue persists when using only the default export

Using named export (works as expected):

App.svelte

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

{ $store }

Type hint for $store shows export const store: string

Using default export (broken):

App.svelte

<script lang="ts">
    import store from './store'
</script>

{ $store }

Type hint for $store shows export const store: Readable<string>

tomblachut commented 2 years ago

Thanks for reporting!

The root cause is that the plugin doesn't follow references from actually exported symbol (and export default is a separate statement that references the variable)

tomblachut commented 1 year ago

Contained in WEB-58397 use the svelte language server.