Visual Studio Error of type "TS2307 Cannot find module", only in IDE

Viewed 911

Using Visual Studio Community 2017, I have multiple sub-projects within a single TypeScript project, and each of these sub-projects is a virtually self-contained project with everything it needs, amongst others its own tsconfig.json, e.g:

{
    "extends": "./../../../tsconfig.json",
    "compilerOptions": {
        "baseUrl": "./src/scripts/application",
        "paths": {
            "@vuex-store/*": [ "store/*" ]
        }
    }
}

As you can see, it inherits from the top-most tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2017"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noResolve": false,
    "removeComments": false,
    "skipLibCheck": true,
    "sourceMap": true,
    "suppressImplicitAnyIndexErrors": true,
    "target": "es2017",
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "exclude": [
    ".awcache",
    ".tsc",
    "bin",
    "node_modules",
    "obj",
    "**/*.spec.ts"
  ],
  "include": [
    "src/**/*.ts",
    "@types/**/*.d.ts"
  ]
}

While trying to import menuModule from "@vuex-store/modules/menu/index"; I can see in the "Errors" tab

TS2307 Cannot find module '@vuex-store/modules/menu/index'

and, if building the project I get the same error from the build engine.

Running the project after a Webpack build works like a charm, so this is definitely a problem with Visual Studio, even though the IDE Visual Studio is able to find and navigate to the module, import and resolve intellisense on "menuModule".

Is it a bug in Visual Studio?

enter image description here

0 Answers
Related