我使用webpack创建了一个Typescript项目,遵循这个教程。 由于我有很多模块,所以我在src/components文件夹中添加了index.d.ts文件,其中我导出了所有的模块:
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扩展名中,就像这里所描述的,但是然后我就得到了另一个错误消息。我有什么遗漏吗?