Skip to content

Commit 417555c

Browse files
committed
implemented treat warning as errors commandline option (warnaserror).
1 parent 290e43b commit 417555c

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

Diff for: src/compiler/commandLineParser.ts

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ module ts {
113113
type: "boolean",
114114
description: Diagnostics.Print_the_compiler_s_version,
115115
},
116+
{
117+
name: "warnAsError",
118+
type: "boolean",
119+
description: Diagnostics.Report_all_warnings_as_errors,
120+
},
116121
{
117122
name: "watch",
118123
shortName: "w",

Diff for: src/compiler/diagnosticInformationMap.generated.ts

+1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ module ts {
364364
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." },
365365
Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." },
366366
Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." },
367+
Report_all_warnings_as_errors: { code: 6007, category: DiagnosticCategory.Message, key: "Report all warnings as errors." },
367368
Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." },
368369
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)" },
369370
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },

Diff for: src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,10 @@
14561456
"category": "Message",
14571457
"code": 6006
14581458
},
1459+
"Report all warnings as errors.": {
1460+
"category": "Message",
1461+
"code": 6007
1462+
},
14591463
"Do not emit comments to output.": {
14601464
"category": "Message",
14611465
"code": 6009

Diff for: src/compiler/tsc.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,17 +362,17 @@ module ts {
362362
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
363363
var checkStart = new Date().getTime();
364364
errors = checker.getDiagnostics();
365-
if (!checker.hasEarlyErrors()) {
365+
if (checker.hasEarlyErrors() || (compilerOptions.warnAsError && errors.length > 0)) {
366+
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
367+
}
368+
else {
366369
var emitStart = new Date().getTime();
367370
var emitOutput = checker.emitFiles();
368371
var emitErrors = emitOutput.errors;
369372
exitStatus = emitOutput.emitResultStatus;
370373
var reportStart = new Date().getTime();
371374
errors = concatenate(errors, emitErrors);
372375
}
373-
else {
374-
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
375-
}
376376
}
377377

378378
reportDiagnostics(errors);

Diff for: src/compiler/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ module ts {
10921092
sourceRoot?: string;
10931093
target?: ScriptTarget;
10941094
version?: boolean;
1095+
warnAsError?: boolean;
10951096
watch?: boolean;
10961097
[option: string]: any;
10971098
}

0 commit comments

Comments
 (0)