svelte-intellij icon indicating copy to clipboard operation
svelte-intellij copied to clipboard

since version 0.21.0 TypeScript imports shows error 'Cannot resolve symbol'

Open dadiborn opened this issue 2 years ago • 6 comments

src/App.svelte :: import {myStore} from './folder/component.store'; << OK src/folder/Component.svelte :: import {myStore} from './component.store'; << broken on 0.21.0 | OK on 0.20.0 src/folder/component.store.ts

Version 0.20.0 was the last version where component.store.ts can be imported to Component.svelte this way: import {myStore} from './component.store';

All version above says "Cannot resolve symbol". On broken versions this can be fixed by adding .ts extension at the end on import like so: import {myStore} from './component.store.ts'; This solution with adding extension is incorrect. The problem appears only on sub folders, import on root level works fine.

dadiborn avatar Oct 26 '21 14:10 dadiborn

Hello, which IDE version are you using? To be honest, I don't fully grasp your example. Could you format it differently?

tomblachut avatar Oct 27 '21 11:10 tomblachut

IDEA 2021.2.3 here is quick example: https://github.com/dadiborn/svelte-ts-import-issues both .svelte files has issues on 0.21.0 and 0.21.1 but 0.20.0 works perfectly

dadiborn avatar Oct 27 '21 17:10 dadiborn

UPDATE: I found that this is naming conflicts. Even "Data.svelte" is starts with capital and in same directory "data.ts" is lowercase, it makes conflict and doesn't work properly. To solve this issue we need to move .ts to sub directory if we want to keep name or just rename it so component and ts files doesn't match.

dadiborn avatar Nov 12 '21 19:11 dadiborn

WebStorm Version: 2021.3 Plugin Version: 0.21.1

/////////////////////////////////////////////////////////////////////// I am also experiencing this

// This will rename the database from "localforage"
  $: count = 0
  $: error = ''
  $: email = '[email protected]'
  $: password = 'password1234567890'
  $: disabled = email.trim() === '' || password.trim() === ''

All variables are highlighted in red and WebStorm says "Unresolved variable or type "

Was working earlier, but WebStorm was in constant analysing mode, so I restarted it. Then all my code went red with errors in .svelte files

Project still runs and no errors in console nor in browser.

Edit: I solved this by putting splitting the variable declaration from the initializes. So above the first $: I put let count, error, email, password, disabled

Once done that the IDE is happy.

AnthoniG avatar Dec 22 '21 10:12 AnthoniG

WebStorm Version: 2021.3 Plugin Version: 0.21.1

/////////////////////////////////////////////////////////////////////// I am also experiencing this

// This will rename the database from "localforage"
  $: count = 0
  $: error = ''
  $: email = '[email protected]'
  $: password = 'password1234567890'
  $: disabled = email.trim() === '' || password.trim() === ''

All variables are highlighted in red and WebStorm says "Unresolved variable or type "

Was working earlier, but WebStorm was in constant analysing mode, so I restarted it. Then all my code went red with errors in .svelte files

Project still runs and no errors in console nor in browser.

I have the same problem, also version 0.21.1. All of reactive variables behaves like that: image

Takitaf avatar Dec 27 '21 21:12 Takitaf

@Takitaf @AnthoniG I haven't seen this reactive variable issues since 0.21.2 On my current setup with all latest updates (for IDE and Plugins) everything works perfectly, so try to update and run File/Invalidate Caches...

dadiborn avatar Dec 29 '21 16:12 dadiborn

This issue was solved some time ago, apologies for not closing it here.

tomblachut avatar Jul 04 '23 17:07 tomblachut