Skip to content

Commit

Permalink
implemented treat warning as errors commandline option (warnaserror).
Browse files Browse the repository at this point in the history
  • Loading branch information
DickvdBrink committed Oct 26, 2014
1 parent 290e43b commit 417555c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'" },
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,17 @@ 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;
exitStatus = emitOutput.emitResultStatus;
var reportStart = new Date().getTime();
errors = concatenate(errors, emitErrors);
}
else {
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
}
}

reportDiagnostics(errors);
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ module ts {
sourceRoot?: string;
target?: ScriptTarget;
version?: boolean;
warnAsError?: boolean;
watch?: boolean;
[option: string]: any;
}
Expand Down

0 comments on commit 417555c

Please sign in to comment.