Fork-ts-checker-webpack-plugin: Feature request: option to warn instead of failing build

Created on 18 Mar 2019  路  8Comments  路  Source: TypeStrong/fork-ts-checker-webpack-plugin

It would be very useful to put this plugin in a mode where type errors are treated as equivalent to lint warnings, instead of failing the build. Maybe something like maximumSeverity: 'warn'?

enhancement

Most helpful comment

I'll have to admit to being appalled by your attitude towards static typing; surely you must want to be entirely type safe right now with no delay 馃榿

That said, there's room in the world for multiple opinions. If you'd like to consider a PR to that end I'll certainly look at it.

All 8 comments

What would the use case of that be?

I'm currently working on a major refactor of my codebase and certain parts of it I know are not working and certainly are not type-correct at the moment. I'm OK with that and I really just need to test the parts that _should_ be working right now.

And in general, my team's mental model of TypeScript is that of a lint tool / test suite, and we are more often annoyed by type errors preventing us from testing the app on the local dev server than helped (most of our lint rules are also set to Warn for this reason). My ideal set up would be one that _warns_ of type errors in the console but does not stop the app from working locally. (obviously, type errors should still cause CI build failures!)

I'll have to admit to being appalled by your attitude towards static typing; surely you must want to be entirely type safe right now with no delay 馃榿

That said, there's room in the world for multiple opinions. If you'd like to consider a PR to that end I'll certainly look at it.

I also would like this. here's my use case:

  • with incremental flag turned on, it happens really fast, so 馃憤
  • however, with this on, you may want to set async to be false again, as it is fast so no worries, and it integrates with plugins better
  • but now you have to fix all TS errors first before you see/test your code. when refactoring/doing a new feature it's nice to be able to see it working while you're going and clean up as you go.

Cool - if someone wants to submit a PR we'll take a look. 馃槉

@dallonf , @kelly-tock
Please try fork-ts-checker-webpack-plugin@alpha - I've published a new version which allows you to filter out issues using predicates (issues options) 馃殌
I will close this issue to clean-up the backlog :)

@piotr-oles As i understand the issues option doesn't show errors from TypeScript. Is it possible to show errors from TS but as warnings (yellow) and don't break webpack. Just for soft migration to from js to ts.

To do that, you can use issues hook. The most convenient way to do that is to create a custom plugin. I wrote this pseudo-code to show you an idea:

import webpack from 'webpack';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';

class ForkTsCheckerWarningWebpackPlugin implements webpack.Plugin {
  apply(compiler: webpack.Compiler) {
    const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);

    hooks.issues.tap(
      'ForkTsCheckerWarningWebpackPlugin',
      (issues) => issues.map(issue => ({ ...issue, severity: 'warning' }))
    );
  }
}

export { ForkTsCheckerWarningWebpackPlugin }
Was this page helpful?
0 / 5 - 0 ratings