Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36aeb6b

Browse files
committed
Do not print error codes by default
1 parent dfeaabe commit 36aeb6b

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/compiler/commandLineParser.ts

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ module ts {
8383
description: Diagnostics.Redirect_output_structure_to_the_directory,
8484
paramType: Diagnostics.DIRECTORY,
8585
},
86+
{
87+
name: "printErrorCodes",
88+
type: "boolean",
89+
},
8690
{
8791
name: "removeComments",
8892
type: "boolean",

src/compiler/tsc.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module ts {
8585
return diagnostic.messageText;
8686
}
8787

88-
function reportDiagnostic(diagnostic: Diagnostic) {
88+
function reportDiagnostic(diagnostic: Diagnostic, options: CompilerOptions) {
8989
var output = "";
9090

9191
if (diagnostic.file) {
@@ -95,14 +95,20 @@ module ts {
9595
}
9696

9797
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
98-
output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine;
98+
output += category;
99+
100+
if (options.printErrorCodes) {
101+
output += " TS" + diagnostic.code;
102+
}
103+
104+
output += ": " + diagnostic.messageText + sys.newLine;
99105

100106
sys.write(output);
101107
}
102108

103-
function reportDiagnostics(diagnostics: Diagnostic[]) {
109+
function reportDiagnostics(diagnostics: Diagnostic[], options: CompilerOptions) {
104110
for (var i = 0; i < diagnostics.length; i++) {
105-
reportDiagnostic(diagnostics[i]);
111+
reportDiagnostic(diagnostics[i], options);
106112
}
107113
}
108114

@@ -207,12 +213,12 @@ module ts {
207213
// If there are any errors due to command line parsing and/or
208214
// setting up localization, report them and quit.
209215
if (commandLine.errors.length > 0) {
210-
reportDiagnostics(commandLine.errors);
216+
reportDiagnostics(commandLine.errors, commandLine.options);
211217
return sys.exit(1);
212218
}
213219

214220
if (commandLine.options.version) {
215-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
221+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version), commandLine.options);
216222
return sys.exit(0);
217223
}
218224

@@ -226,7 +232,7 @@ module ts {
226232

227233
if (commandLine.options.watch) {
228234
if (!sys.watchFile) {
229-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
235+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), commandLine.options);
230236
return sys.exit(1);
231237
}
232238

@@ -250,7 +256,7 @@ module ts {
250256

251257
// Compile the program the first time and watch all given/referenced files.
252258
var program = compile(commandLine, compilerHost).program;
253-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
259+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes), commandLine.options);
254260
addWatchers(program);
255261
return;
256262

@@ -290,7 +296,7 @@ module ts {
290296
}
291297

292298
function recompile(changedFiles: Map<boolean>) {
293-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling));
299+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling), commandLine.options);
294300
// Remove all the watchers, as we may not be watching every file
295301
// specified since the last compilation cycle.
296302
removeWatchers(program);
@@ -317,7 +323,7 @@ module ts {
317323
};
318324

319325
program = compile(commandLine, newCompilerHost).program;
320-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
326+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes), commandLine.options);
321327
addWatchers(program);
322328
}
323329

@@ -347,7 +353,7 @@ module ts {
347353
errors = concatenate(semanticErrors, emitErrors);
348354
}
349355

350-
reportDiagnostics(errors);
356+
reportDiagnostics(errors, commandLine.options);
351357
if (commandLine.options.diagnostics) {
352358
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
353359
reportCountStatistic("Files", program.getSourceFiles().length);

src/compiler/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ module ts {
987987
noResolve?: boolean;
988988
out?: string;
989989
outDir?: string;
990+
printErrorCodes?: boolean;
990991
removeComments?: boolean;
991992
sourceMap?: boolean;
992993
sourceRoot?: string;

0 commit comments

Comments
 (0)