Closed shorn closed 1 year ago
It seems to be mentioned in #223 already
@r00t3g yeah you're right, anyway let's keep this issue since there's nice workaround specified.
Here's the original mention:
I ran into a similiar problem with context="module"
. Their exports are also not visible although it compiles and works fine
Provider.svelte
<script context='module' lang='ts'>
export const foo:string = 'bar';
</script>
Main.svelte (with workaround)
<script lang='ts'>
import {foo as _foo} from './Provider.svelte'; // foo is in red - not found
const foo = _foo as string; // Workaround to get the typing back
</script>
Originally posted by @Treverix in https://github.com/tomblachut/svelte-intellij/issues/223#issuecomment-859934247
I've found another workaround that's pretty simple and automatically imports types:
<script lang="ts" context="module">
import App, * as _App from "./App.svelte"
let { gui, Button } = _App;
...
</script>
<App />
<script lang="ts" context="module">
...
let gui = new GUIClass();
enum Button { Encrypt, Decrypt, Help }
...
export { gui, Button }
</script>
...
Works like a charm in WebStorm.
I am also experiencing this issue - it would be nice if we could get support for this 🙂
Migrated to WEB-54714 Svelte: modules exported from a 'context="module"' script block of the other component not resolved
I am using Typescript with Svelte, IDEA version 2021.1.3 and plugin version 0.20.0
It is valid Svelte code to declare module based constant exports in a svelte component like this:
This constant can then be imported in a different svelte component with this code:
See this REPL for an example of working code: , which I found linked at this StackOverflow answer.
The Svelte plugin will report in IDEA that the import is in error because
cannot resolve symbol 'answer'
. However the Svelte app compiles and works fine.I can work around this by declaring the constant in a third standard
.ts
file and importing it into both Svelte components.Or, I can add
// noinspection TypeScriptCheckImport
to disable the import check (and thus the error) for that statement.This issue is raised to request that the plugin be enhanced to make IDEA aware of exports from Svelte
context="module"
script blocks.