-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Feature request: option to warn instead of failing build #232
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:
|
Cool - if someone wants to submit a PR we'll take a look. 😊 |
@dallonf , @kelly-tock |
@piotr-oles As i understand the |
To do that, you can use 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 } |
Thank you @piotr-oles. Here is a solution that I adapted from your example for webpack 5: typescript-warn-only-webpack-plugin.js const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
class TypeScriptWarnOnlyWebpackPlugin {
apply(compiler) {
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
hooks.issues.tap("TypeScriptWarnOnlyWebpackPlugin", (issues) =>
issues.map((issue) => ({ ...issue, severity: "warning" }))
);
}
}
module.exports = TypeScriptWarnOnlyWebpackPlugin; webpack.config.js const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const TypeScriptWarnOnlyWebpackPlugin = require("./typescript-warn-only-webpack-plugin");
module.exports = {
plugins: [
new ForkTsCheckerWebpackPlugin(),
new TypeScriptWarnOnlyWebpackPlugin(),
],
ignoreWarnings: [/warning from compiler/, (warning) => true],
}; |
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'
?The text was updated successfully, but these errors were encountered: