Skip to content

Commit b315170

Browse files
author
Josh Goldberg
committed
Converted to enum; marked internal
1 parent 98b64db commit b315170

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/compiler/program.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,22 @@ namespace ts {
242242
}
243243

244244
/** @internal */
245-
export const foregroundColorEscapeSequences = {
246-
grey: "\u001b[90m",
247-
red: "\u001b[91m",
248-
yellow: "\u001b[93m",
249-
blue: "\u001b[94m",
250-
cyan: "\u001b[96m"
251-
};
245+
export enum ForegroundColorEscapeSequences {
246+
Grey = "\u001b[90m",
247+
Red = "\u001b[91m",
248+
Yellow = "\u001b[93m",
249+
Blue = "\u001b[94m",
250+
Cyan = "\u001b[96m"
251+
}
252252
const gutterStyleSequence = "\u001b[30;47m";
253253
const gutterSeparator = " ";
254254
const resetEscapeSequence = "\u001b[0m";
255255
const ellipsis = "...";
256256
function getCategoryFormat(category: DiagnosticCategory): string {
257257
switch (category) {
258-
case DiagnosticCategory.Warning: return foregroundColorEscapeSequences.yellow;
259-
case DiagnosticCategory.Error: return foregroundColorEscapeSequences.red;
260-
case DiagnosticCategory.Message: return foregroundColorEscapeSequences.blue;
258+
case DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
259+
case DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
260+
case DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
261261
}
262262
}
263263

@@ -311,7 +311,7 @@ namespace ts {
311311

312312
// Output the gutter and the error span for the line using tildes.
313313
context += formatColorAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
314-
context += foregroundColorEscapeSequences.red;
314+
context += ForegroundColorEscapeSequences.Red;
315315
if (i === firstLine) {
316316
// If we're on the last line, then limit it to the last character of the last line.
317317
// Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
@@ -330,18 +330,18 @@ namespace ts {
330330
context += resetEscapeSequence;
331331
}
332332

333-
output += formatColorAndReset(relativeFileName, foregroundColorEscapeSequences.cyan);
333+
output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan);
334334
output += "(";
335-
output += formatColorAndReset(`${ firstLine + 1 }`, foregroundColorEscapeSequences.yellow);
335+
output += formatColorAndReset(`${ firstLine + 1 }`, ForegroundColorEscapeSequences.Yellow);
336336
output += ",";
337-
output += formatColorAndReset(`${ firstLineChar + 1 }`, foregroundColorEscapeSequences.yellow);
337+
output += formatColorAndReset(`${ firstLineChar + 1 }`, ForegroundColorEscapeSequences.Yellow);
338338
output += "): ";
339339
}
340340

341341
const categoryColor = getCategoryFormat(diagnostic.category);
342342
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
343343
output += formatColorAndReset(category, categoryColor);
344-
output += formatColorAndReset(` TS${ diagnostic.code }: `, foregroundColorEscapeSequences.grey);
344+
output += formatColorAndReset(` TS${ diagnostic.code }: `, ForegroundColorEscapeSequences.Grey);
345345
output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
346346

347347
if (diagnostic.file) {

src/compiler/watch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ namespace ts {
4848
};
4949
}
5050

51+
/** @internal */
5152
export function createWatchDiagnosticReporterWithColor(system = sys): DiagnosticReporter {
5253
return diagnostic => {
53-
let output = `[${ formatColorAndReset(new Date().toLocaleTimeString(), foregroundColorEscapeSequences.grey) }] `;
54+
let output = `[${ formatColorAndReset(new Date().toLocaleTimeString(), ForegroundColorEscapeSequences.Grey) }] `;
5455
output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${system.newLine + system.newLine + system.newLine}`;
5556
system.write(output);
5657
};

0 commit comments

Comments
 (0)