tomblachut / svelte-intellij

Svelte components in WebStorm and friends

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$store type is not detected when using default export

Bickio opened this issue · comments

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>

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)

Contained in WEB-58397 use the svelte language server.