diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a7993484c64..210c71541f3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -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", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a5dda0b1f4b..5ab076413cc 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -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'" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 1336af21aaf..2442d21d206 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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 diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 15f231bc74e..dff2ac8d0b1 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -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); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index aa2ca3b4ba8..d96a50b8e84 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1092,6 +1092,7 @@ module ts { sourceRoot?: string; target?: ScriptTarget; version?: boolean; + warnAsError?: boolean; watch?: boolean; [option: string]: any; }