TypeScript: [Bug] TS doesn't detect webpack aliases?

From @Luchillo on July 13, 2016 19:20

  • VSCode Version: 1.3.1
  • OS Version: Ubuntu 15.10

Steps to Reproduce:

I have a webpack config with an alias for an import path, VSCode doesn’t recognize this, i’ve tried with the tsconfig.json’s paths option:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "filesGlob": [
    "**/*.ts",
    "!node_modules/**/*"
  ],
  "exclude": [
    "node_modules",
    "typings/global",
    "typings/global.d.ts"
  ],
  "paths": {
    "tao-animations": "app/theme/core/app.tao-animations.ts"
  },
  "compileOnSave": true,
  "atom": {
    "rewriteTsconfig": false
  }
}

But it still doesn’t find the module even if webpack compiles ok: image

Copied from original issue: Microsoft/vscode#9227

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

I have a similar problem with webpack module resolution.

Here’s the webpack config:

resolve: {
    extensions: ['.js', '.vue', '.json', '.ts', '.gql', '.graphql'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
    }
  },

and tsconfig.json

"baseUrl": "./",
    "paths": {
      "@": ["src"]
    },

In a .ts file, import HelloWorld from '@/components/HelloWorld' triggers a module not found problem on VSCode. Changing it to import HelloWorld from '@/components/HelloWorld.vue' makes the error disappear.

How to add module extension resolution to tsconfig.json ? I’ve not found anything related in the doc, nor in issues.

Ok now it works, what happened was i had the baseUrl property outside the compiler options, i think moving it to that section was the fix.