ivogabe / gulp-typescript

A TypeScript compiler for gulp with incremental compilation support.
MIT License
831 stars 129 forks source link

Ignore errors from node_modules #629

Closed HoldYourWaffle closed 4 years ago

HoldYourWaffle commented 4 years ago

Expected behavior: I want to ignore (semantic) compilation errors from files residing in node_modules.

Actual behavior: All (semantic) errors fail the build.

Your gulpfile:

const { src, dest } = require('gulp');
const ts = require('gulp-typescript');

const tsProject = ts.createProject('../tsconfig.json');

exports.default = function compile() {
    const tsResult = src([
        // ... snip ...
    ]).pipe(tsProject());

    return tsResult.js.pipe(dest('../dist'));
}

tsconfig.json

Include your tsconfig, if related to this issue.

{
    "compileOnSave": true,

    "compilerOptions": {
        "target": "es5",
        "sourceMap": true,

        "module": "commonjs",
        "jsx": "react",
        "moduleResolution": "node",

        "baseUrl": ".",
        "paths": {
            "*": [ "node_modules/*" ]
        },

        "allowJs": true,
        "strict": true,
        "noImplicitReturns": true,

        "esModuleInterop": true,
        "resolveJsonModule": true,
        "allowSyntheticDefaultImports": true,
        "forceConsistentCasingInFileNames": true,

        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    }
}
Epskampie commented 4 years ago

Why are you doing?

        "baseUrl": ".",
        "paths": {
            "*": [ "node_modules/*" ]
        },

I believe those are the defaults and can be left out. Also, you might try the exclude option:

"exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]

https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

ivogabe commented 4 years ago

It is not possible to ignore those errors, and in my opinion also not desired as it may make type inferencing unpredictable. It sounds indeed like a configuration error, see also the FAQ of TypeScript..

I'll close this issue as it not specifically targets gulp-typescript and is more related to TypeScript.