64

I'm running this task:

{
        "taskName": "tsc watch",
        "command": "tsc -w",
        "type": "shell",
        "problemMatcher": "$tsc-watch"
}

with this tsconfig:

{
    "compileOnSave": true,
    "files": [
        "src/index.ts"
    ],
    "compilerOptions": {
        "module": "commonjs",
        "sourceMap": true,
        "outDir": "dist/"
    },
    "exclude": [
        "node_modules"
    ]
}

the file index.ts only has one line in it:

console.log('Is it working?');

And the "problems" tab is filled with HTML related warnings from random npm modules. Why? And how do i stop it?

Edit1:
I managed to find a hack that works, by excluding the node_modules folder from the explorer:

/* settings.json */
{
    "files.exclude": {
        "**/node_modules": true
    }
}

However this is a hack, and i still want a proper answer..

Olian04
  • 6,480
  • 2
  • 27
  • 54

3 Answers3

129

I stumbled upon this issue as well. The only solution I found was add the skipLibCheck option and set it to true in the compilerOptions of my tsconfig.json:

{
    "compilerOptions": {
        "skipLibCheck": true
    }
}

According to the doc, it will skip type checking of all declaration files (*.d.ts), which were the ones throwing the warnings in my case.

Boris Yakubchik
  • 3,861
  • 3
  • 34
  • 41
Matthias Thomas Lamotte
  • 1,476
  • 1
  • 12
  • 10
3

All you should need is a tsconfig.json with:

{
    "compilerOptions": {
        "skipLibCheck": true,
    }
}
duhaime
  • 25,611
  • 17
  • 169
  • 224
-1

I have found another "cheat" for making that problem disappear after I tried everything and nothing worked. I added at the end of the file:

export {}

This somehow worked. I am not happy with that solution but that's the only thing that worked for me.

Ofirfr
  • 76
  • 1
  • 5