如何使Svelte知道自定义* .d.ts文件?

问题描述

我想将一些*.txt文件作为字符串导入到苗条的组件中。以下打字稿代码在VS代码中不发出警告:

// global.d.ts
declare module "*.txt" {
    const content: string;
    export default content;
}
// test.ts
import txt from "./test.txt";

但是,如果我尝试将相同的文本文件导入Svelte组件(虽然global.d.ts仍然存在):

// Test.svelte
<script type="typescript">
    import txt from "./test.txt";
</script>

,VS Code将抱怨Cannot find module './test.txt' or its corresponding type declarations. ts(2307)。那么如何正确地告诉Svelte关于global.d.ts中的声明?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)