Search code examples
typescriptwebpackmoduleresolution

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?


Solution

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