Exclude node_modules from "problems"

Olian04 picture Olian04 · Jul 23, 2017 · Viewed 12.1k times · Source

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

Answer

Matthias Thomas Lamotte picture Matthias Thomas Lamotte · Aug 17, 2017

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": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "skipLibCheck": true,
        "rootDir": "client/app"
    },
    "exclude": [
        "client/node_modules/"
    ]
}

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.