Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore errors from gulp-typescript? #651

Open
vedantroy opened this issue May 11, 2020 · 2 comments
Open

How to ignore errors from gulp-typescript? #651

vedantroy opened this issue May 11, 2020 · 2 comments

Comments

@vedantroy
Copy link

vedantroy commented May 11, 2020

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.

@sirzdy
Copy link

sirzdy commented Jun 22, 2020

I have the same problem, have you solved yet?

@j-oliveras
Copy link
Contributor

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)),
    ]);
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants