2016-07-07 58 views
5

我使用webpack创建了Typescript项目,跟在this tutorial之后。 由于我有很多的模块,我加index.d.ts我的src /组件,其中我出口我的所有模块的文件夹:Typescript,index.d.ts和webpack:找不到模块错误

export {Module1} from "./Module1"; 
export {Module2} from "./Module2"; 
export {Module3} from "./Module3"; 

我加index.d.ts到tsconfig.json文件:

"files": [ 
    "./src/components/index.d.ts" 
] 

然后,在index.tsx,这是在src文件夹中,我输入:

import * as MyModule from "./components/"; 

代码提示工作得很好,所以我想所有的路径都OK。 然而,当我运行的WebPack,我得到这个错误:

模块未找到:错误:无法解析目录” ./components'

据我了解,的WebPack没有找到这个index.d。 ts文件。我尝试将d.ts添加到webpack.config.js扩展名,例如described here,但后来我收到了一条不同的错误消息。我错过了什么吗?

回答

2

想出了一个解决方案,将index.ts用于所有导出,而不是index.d.ts。

相关问题