From b044e715612b4b2f60da99e775a5bd200e464cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20Ledoux?= Date: Sun, 8 Aug 2021 16:59:54 -0500 Subject: [PATCH] fix: allow to specify pretty errors in TTY (#1420) * fix: allow to specify pretty errors in TTY closes #1418 * lint fix Co-authored-by: Andrew Bradley --- src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index acbc892a9..c9b4f0483 100644 --- a/src/index.ts +++ b/src/index.ts @@ -675,10 +675,12 @@ export function create(rawOptions: CreateOptions = {}): Service { }, }); - const formatDiagnostics = - process.stdout.isTTY || options.pretty - ? ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics - : ts.formatDiagnostics; + const shouldHavePrettyErrors = + options.pretty === undefined ? process.stdout.isTTY : options.pretty; + + const formatDiagnostics = shouldHavePrettyErrors + ? ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics + : ts.formatDiagnostics; function createTSError(diagnostics: ReadonlyArray<_ts.Diagnostic>) { const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);