Search code examples
typescriptvue.jswebstorm

TypeScript error is not being hightlighted when Vue framework is being used in IntelliJ IDEA IDEs


When Vue framework is being used, in the right bottom corner, Vue label before TypeScript 〈version〉 is being displayed:

enter image description here

What wrong is in this Vue mode, the TypeScript errors highlighting does not work even outside of .vue files. For example, I'll declare the const without initialization. Normally, it will cause at least TS1155: 'const' declarations must be initializaed:

enter image description here

But in the project with Vue, GUI will not notify about TypeScript errors:

enter image description here

ESLint is complying but TypeScript is no.


Solution

  • The IDE needs to know which tsconfig.json do each TypeScript file obeys. To specify it, either files or include must be filled.

    In the files case, besides specific files we can specify also directories:

    {
      "compilerOptions": {
        "baseUrl": "./"
      },
      "files": [
        "Source",
        "Tests"
      ]
    }
    

    enter image description here

    In the include case, although "include": [ "Source/**/*", "Tests/**/*" ] is valid TypeScript config, the IDE will not understand it:

    enter image description here

    To fix it, append ./ to each pattern:

    {
      "compilerOptions": {
        "baseUrl": "./"
      },
      "include": [
        "./Source/**/*",
        "./Tests/**/*"
      ]
    }
    

    enter image description here