From 4b235eca17475ce0991a1d7047b6369925eefb4f Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Fri, 4 Jun 2021 10:05:48 +1000 Subject: [PATCH] fix: check if sysFormatDiagnosticsHost is defined (#44344) * fix: check if sysFormatDiagnosticsHost is defined * improve types --- src/compiler/watch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 90346bbd726..78dc1413447 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -1,16 +1,16 @@ /*@internal*/ namespace ts { - const sysFormatDiagnosticsHost: FormatDiagnosticsHost = sys ? { + const sysFormatDiagnosticsHost: FormatDiagnosticsHost | undefined = sys ? { getCurrentDirectory: () => sys.getCurrentDirectory(), getNewLine: () => sys.newLine, getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames) - } : undefined!; // TODO: GH#18217 + } : undefined; /** * Create a function that reports error by writing to the system and handles the formating of the diagnostic */ export function createDiagnosticReporter(system: System, pretty?: boolean): DiagnosticReporter { - const host: FormatDiagnosticsHost = system === sys ? sysFormatDiagnosticsHost : { + const host: FormatDiagnosticsHost = system === sys && sysFormatDiagnosticsHost ? sysFormatDiagnosticsHost : { getCurrentDirectory: () => system.getCurrentDirectory(), getNewLine: () => system.newLine, getCanonicalFileName: createGetCanonicalFileName(system.useCaseSensitiveFileNames),