implemented treat warning as errors commandline option (warnaserror).

This commit is contained in:
Dick van den Brink 2014-10-26 14:53:26 +01:00
parent 290e43ba29
commit 417555c9e9
5 changed files with 15 additions and 4 deletions

View file

@ -113,6 +113,11 @@ module ts {
type: "boolean",
description: Diagnostics.Print_the_compiler_s_version,
},
{
name: "warnAsError",
type: "boolean",
description: Diagnostics.Report_all_warnings_as_errors,
},
{
name: "watch",
shortName: "w",

View file

@ -364,6 +364,7 @@ module ts {
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." },
Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." },
Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." },
Report_all_warnings_as_errors: { code: 6007, category: DiagnosticCategory.Message, key: "Report all warnings as errors." },
Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },

View file

@ -1456,6 +1456,10 @@
"category": "Message",
"code": 6006
},
"Report all warnings as errors.": {
"category": "Message",
"code": 6007
},
"Do not emit comments to output.": {
"category": "Message",
"code": 6009

View file

@ -362,7 +362,10 @@ module ts {
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
var checkStart = new Date().getTime();
errors = checker.getDiagnostics();
if (!checker.hasEarlyErrors()) {
if (checker.hasEarlyErrors() || (compilerOptions.warnAsError && errors.length > 0)) {
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
}
else {
var emitStart = new Date().getTime();
var emitOutput = checker.emitFiles();
var emitErrors = emitOutput.errors;
@ -370,9 +373,6 @@ module ts {
var reportStart = new Date().getTime();
errors = concatenate(errors, emitErrors);
}
else {
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
}
}
reportDiagnostics(errors);

View file

@ -1092,6 +1092,7 @@ module ts {
sourceRoot?: string;
target?: ScriptTarget;
version?: boolean;
warnAsError?: boolean;
watch?: boolean;
[option: string]: any;
}