gulp-typescript icon indicating copy to clipboard operation
gulp-typescript copied to clipboard

How to ignore errors from gulp-typescript?

Open vedantroy opened this issue 5 years ago • 2 comments

I have a legacy project with broken/missing types, but I want to emit the code anyway.

Here's a small bit of code:

function tsPipeline(src, dst, extraLibs) {
  return function () {
    const build = gulp.src(src).pipe(
      ts({
        target: "es5",
        module: "commonjs",
        declaration: true,
        noImplicitAny: true,
        removeComments: true,
        experimentalDecorators: true,
        newLine: "LF",
        lib: [
          "DOM",
          "DOM.Iterable",
          "ScriptHost",
          "es2016",
          "es2017.sharedmemory",
        ],
      })
    );

    return merge([
      build.dts.pipe(gulp.dest(dst)),
      build.js.pipe(gulp.dest(dst)),
    ]);
  };
}

Is there a way to make this function tsPipeline not crash the task it belongs to, even if there are errors in the types? I know this is bad practice, but I just need to get this old legacy code to build regardless of the cost.

vedantroy avatar May 11 '20 00:05 vedantroy

I have the same problem, have you solved yet?

sirzdy avatar Jun 22 '20 08:06 sirzdy

Add .on("error", () => { /* Ignore compiler errors */}) at end of build:

function tsPipeline(src, dst, extraLibs) {
  return function () {
    const build = gulp.src(src).pipe(
      ts({
        target: "es5",
        module: "commonjs",
        declaration: true,
        noImplicitAny: true,
        removeComments: true,
        experimentalDecorators: true,
        newLine: "LF",
        lib: [
          "DOM",
          "DOM.Iterable",
          "ScriptHost",
          "es2016",
          "es2017.sharedmemory",
        ],
      })
    ).
    on("error", () => { /* Ignore compiler errors */});

    return merge([
      build.dts.pipe(gulp.dest(dst)),
      build.js.pipe(gulp.dest(dst)),
    ]);
  };
}

j-oliveras avatar Jun 29 '20 14:06 j-oliveras