svelte-intellij
svelte-intellij copied to clipboard
$store type is not detected when using default export
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.