我不知道如何使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进行模块检查?
我解决了问题。这是由于缺乏TS知识。要查找模块,我只需要在declare module
文件中使用*.d.ts
对其进行声明。