首页 > 解决方案 > Is it possible to mimic webpack custom module resolution in TypeScript?

问题描述

I can't find out how to make TS check for modules not only node_modules directory but other custom directories too.

My situation:

# 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.

So, is it possible to make TS check for modules like webpack does?

标签: typescriptwebpackmoduleresolution

解决方案


I solved the problem. It was due to a lack of knowledge of TS. To find modules I just need to declare them using declare module in *.d.ts files.


推荐阅读