From 07d56898ee360f4be2a5b954d8a0531e7344d6b7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Aug 2014 16:52:39 -0700 Subject: [PATCH] Emit error codes when reporting diagnostics. Addresses part of issue #506. --- src/compiler/tsc.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d355c49ab29..abefd6e4819 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -86,13 +86,18 @@ module ts { } function reportDiagnostic(diagnostic: Diagnostic) { + var output = ""; + if (diagnostic.file) { var loc = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); - sys.write(diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): " + diagnostic.messageText + sys.newLine); - } - else { - sys.write(diagnostic.messageText + sys.newLine); + + var output = diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): "; } + + var category = DiagnosticCategory[diagnostic.category]; + output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine; + + sys.write(output); } function reportDiagnostics(diagnostics: Diagnostic[]) {