From 88fb2b2ce83b7f2e8066c8e9abf13afdf76927fc Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 5 Aug 2021 09:27:37 -0500 Subject: [PATCH 1/2] fix: allow to specify pretty errors in TTY closes #1418 --- src/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5360a86a0..3dbc92d05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -625,8 +625,13 @@ export function create(rawOptions: CreateOptions = {}): Service { }, }); - const formatDiagnostics = - process.stdout.isTTY || options.pretty + const shouldHavePrettyErrors = + options.pretty === undefined + ? process.stdout.isTTY + : options.pretty + + const formatDiagnostics = + shouldHavePrettyErrors ? ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics : ts.formatDiagnostics; From e9c31b0fc7f656eef5276c1e769aa38571da102f Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 8 Aug 2021 17:42:00 -0400 Subject: [PATCH 2/2] lint fix --- src/index.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index ff246725e..c9b4f0483 100644 --- a/src/index.ts +++ b/src/index.ts @@ -675,15 +675,12 @@ export function create(rawOptions: CreateOptions = {}): Service { }, }); - const shouldHavePrettyErrors = - options.pretty === undefined - ? process.stdout.isTTY - : options.pretty - - const formatDiagnostics = - shouldHavePrettyErrors - ? 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);