#IntelliJ ## 事象 [[Svelte]]ファイルでexportした変数やtype、[[インターフェース (TypeScript)|インターフェース]]が別の[[TypeScript]]ファイルからimportできない。 ```ts:Hoge.svelte <script lang="ts"> type Hoge = { id: string; }; </script> ``` ```ts:main.ts import type {hoge} from "./component/Hoge.svelte"; ``` ↓ 以下のようなエラーになる。 ``` TS2614: Module '"*.svelte"' has no exported member 'Hoge' ``` ## 解決方法 現時点で2つがどちらもオススメできない。 <div class="link-card"> <div class="link-card-header"> <img src="https://github.githubassets.com/favicons/favicon.svg" class="link-card-site-icon"/> <span class="link-card-site-name">GitHub</span> </div> <div class="link-card-body"> <div class="link-card-content"> <div> <p class="link-card-title">Typescript: Exported members from Svelte modules cannot be detected from Typescript files · Issue #5817 · sveltejs/svelte</p> </div> <div class="link-card-description"> Describe the bug When using Typescript, exported properties from a component&#39;s context=&quot;mod... </div> </div> <img src="https://opengraph.githubassets.com/d5b1987357d126805abc629ba37019ba5e5fb2fe3114b96742a93b3d6447b364/sveltejs/svelte/issues/5817" class="link-card-image" /> </div> <a href="https://github.com/sveltejs/svelte/issues/5817"></a> </div> ### その1 `*.d.ts`ファイルに該当のexportを型定義してあげればimportできる。ただ、常に整合性をあわせる必要があり、シグニチャが重複する可能性もあるのでおオススメできない。 ### その2 importしている`*.ts`ファイルを、`*.ts.svelte`として[[Svelte]]ファイルでwrapしてあげればimportできる。ただ、[[Svelte]]コンポーネントでないファイルをそうするのは非常によろしくない。 ## 関連Issue こちらが解消されるのを見守った方がいい。 - [bundler error when exporting from a svelte component module context script · Issue \#7304 · sveltejs/svelte](https://github.com/sveltejs/svelte/issues/7304)