【发布时间】:2016-11-10 03:04:43
【问题描述】:
我使用 webpack 创建了 Typescript 项目,遵循 this tutorial。 因为我有很多模块,所以我将 index.d.ts 添加到了我的 src/components 文件夹中,我导出了所有模块:
export {Module1} from "./Module1";
export {Module2} from "./Module2";
export {Module3} from "./Module3";
我将 index.d.ts 添加到 tsconfig.json 文件中:
"files": [
"./src/components/index.d.ts"
]
然后,在 src 文件夹中的 index.tsx 中,我导入:
import * as MyModule from "./components/";
代码提示工作正常,所以我想所有路径都可以。 但是当我运行 webpack 时,我得到了这个错误:
找不到模块:错误:无法解析目录“./components”
据我了解,webpack 没有找到这个 index.d.ts 文件。我尝试将 d.ts 添加到 webpack.config.js 扩展中,例如 described here,但随后我收到了不同的错误消息。我错过了什么吗?
【问题讨论】:
标签: typescript