是否可以在TypeScript中模拟webpack定制模块的分辨率?

问题描述 投票:0回答:1

我不知道如何使TS不仅检查node_modules目录,而且检查其他自定义目录的模块。

我的情况:

# webpack config
resolve: {
  modules: ['components', 'node_modules']
}

# index.vue
import WorkspaceToolbar from 'WorkspaceToolbar' // TS can't find this module since it doesn't look in components dir.

因此,是否可以像Webpack一样对TS进行模块检查?

typescript webpack module resolution
1个回答
0
投票

我解决了问题。这是由于缺乏TS知识。要查找模块,我只需要在declare module文件中使用*.d.ts对其进行声明。

© www.soinside.com 2019 - 2024. All rights reserved.