Closed JakubKoralewski closed 3 years ago
Please:
interfaceStore
, ypu only showed interface
. Also full declaration ofinterface
would be helpfulI know about some problems for stores defined in Svelte files but your case seems different, IDK what's happening for now.
That was a mistake. It should have been export interfaceStore: Writable<MyStoreType> = ...
. I won't edit the comment for posterity.
I really think there's no point to showing the declaration of interfaceStore
. It's just an object and this autosubscription type inference worked really well for a good while for me with this same object, I don't know what is happening either. If you insist I created a simplified gist here.
I found a more direct issue. The interfaceStore
import inside index.svelte
only had the type of Writable<MyStoreType>
because I annotated that type on export in store.ts
: export const interfaceStore: Writable<MyStoreType> = ...
.
If I remove this type annotation: (It's actually now correct). Looking into the type of function export const interfaceStore = ...
it turns out this type is actually any
.writable
that is imported at the very top of store.ts
it has the type of import writable
. So it has lost its actual type information.
the above is inside a typescript file mind you, but the below is in the same file (store.ts
) and still it has type for the return value (!?)
Go to declaration functionality still works on writable
, but for some reason the type information is gone, if I'm correct? If I normally import a function it has a dark yellow sort of color, but this looks totally white.
Check this, valid import:
This import as compared to the below (IInterfaceStore
is an interface):
I also tried importing my interface from a typescript file. It works correctly and shows the right type without me having to annotate it. Only inside svelte
files the type of the imported interfaceStore
is any
, and so is $interfaceStore
.
I tried invalidating and restarting multiple times.
Thanks for your time. I think this could be some simple/weird problem possibly unrelated to Svelte-intellij, since it worked before as expected.
Looks like I have even trouble with permissions when deleting node_modules
. Spooky. Maybe a good old restart will help. It didn't.
I don't know what's happening, sorry. I've pasted your gists into TS project and everything seems to be working.
You may try to reproduce your issues in freshly setup project, IDK.
Closing for now, please reach out if still experiencing issues.
My import:
Where
$interfaceStore
has type ofWritable<MyStoreType>
(according to IntelliJ's IntelliSense).According to intellisense it is
Writable<MyStoreType>
.The project itself builds fine. I tried invalidating cache and restarting but it didn't help. It's one of those problems that's hard to make a repro for since it'll probably work for you.
Is there anything I can check to make sure there isn't some simple reason for this? EDIT: versions: Svelte-intellij 0.15.2 WebStorm 2020.2.3 Build #WS-202.7660.23, built on September 30, 2020 Registry: editor.distraction.free.mode=true, eslint.additional.file.extensions=svelte Non-Bundled Plugins: AceJump, IdeaVIM, org.jetbrains.IdeaVim-EasyMotion, org.toml.lang, dev.blachut.svelte.lang
EDIT2: The way the error actually presents itself is in a method call which expects
MyStoreType
as a parameter, but when I pass in$interfaceStore
the error says thatArgument type Writable<MyStoreType> is not assignable to parameter type MyStoreType
. I wanted to add this detail because the Intellisense I mentioned probably looked at the import and showed meinterfaceStore
's type and not$interfaceStore
's type...