tomblachut / svelte-intellij

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

Problem with Typescript and reactive declaration, "Unresolved variable or type" #167

Closed guihig closed 4 years ago

guihig commented 4 years ago

When using "lang='ts'" in the script tag, i am supposing that intellij wont recognize svelte syntax $: and throw the message bellow:

Screenshot from 2020-10-20 11-25-43

If that behavior does not come from the svelte plugin just ignore this issue and forgive me for the missundertood.

tomblachut commented 4 years ago

This should work, I'll verify it later, in the meantime can you provide your IDE version?

guihig commented 4 years ago
PyCharm 2020.2.3 (Professional Edition)
Build #PY-202.7660.27, built on October 6, 2020
Licensed to Guilherme Ferreira
Subscription is active until June 21, 2021
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.8.14-arch1-1
GC: ParNew, ConcurrentMarkSweep
Memory: 1933M
Cores: 16
Registry: ide.intellij.laf.enable.animation=true, ide.browser.jcef.preinit=false, debugger.watches.in.variables=false, ide.balloon.shadow.size=0, eslint.additional.file.extensions=svelte, ide.browser.jcef.enabled=false
Non-Bundled Plugins: IdeaVIM, Key Promoter X, com.vecheslav.darculaDarkerTheme, com.vincentp.gruvbox-theme, de.netnexus.camelcaseplugin, mobi.hsz.idea.gitignore, name.kropp.intellij.makefile, org.toml.lang, dev.blachut.svelte.lang, intellij.prettierJS, org.jetbrains.plugins.vue, com.leinardi.pycharm.mypy, ru.meanmail.plugin.requirements, ru.adelf.idea.dotenv
Current Desktop: Undefined
anstarovoyt commented 4 years ago

@tomblachut actually I haven't checked this case before sending the PR :(

tomblachut commented 4 years ago

@guihig this is in fact a bug, thanks for reporting.

@anstarovoyt I didn't either 😅 happens to best of us. We need to add more tests next time.

tomblachut commented 4 years ago

Interesting, this works

<script lang="ts">
    let base = 1;
    $: declaration = base * 2;
</script>

but this doesn't:

<script lang="ts">
    import {anything} from "./whatever";

    let base = 1;
    $: declaration = base * 2;
</script>
tomblachut commented 4 years ago

Ahh yeah without import export it's treated as non-ESModule

tomblachut commented 4 years ago

@anstarovoyt SvelteTypeScriptReferenceExpressionResolver.createLocalResolveProcessor is never called so my hack with SvelteSinkResolveProcessor does not work

guihig commented 4 years ago

@guihig this is in fact a bug, thanks for reporting.

@anstarovoyt I didn't either sweat_smile happens to best of us. We need to add more tests next time.

Glad to help.

If there is anything I can help with, don't hesitate to ask me.

tomblachut commented 4 years ago

v0.15.1 contains a fix