Skip to content

Commit 4b235ec

Browse files
authored
fix: check if sysFormatDiagnosticsHost is defined (microsoft#44344)
* fix: check if sysFormatDiagnosticsHost is defined * improve types
1 parent cec2fda commit 4b235ec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/watch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*@internal*/
22
namespace ts {
3-
const sysFormatDiagnosticsHost: FormatDiagnosticsHost = sys ? {
3+
const sysFormatDiagnosticsHost: FormatDiagnosticsHost | undefined = sys ? {
44
getCurrentDirectory: () => sys.getCurrentDirectory(),
55
getNewLine: () => sys.newLine,
66
getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames)
7-
} : undefined!; // TODO: GH#18217
7+
} : undefined;
88

99
/**
1010
* Create a function that reports error by writing to the system and handles the formating of the diagnostic
1111
*/
1212
export function createDiagnosticReporter(system: System, pretty?: boolean): DiagnosticReporter {
13-
const host: FormatDiagnosticsHost = system === sys ? sysFormatDiagnosticsHost : {
13+
const host: FormatDiagnosticsHost = system === sys && sysFormatDiagnosticsHost ? sysFormatDiagnosticsHost : {
1414
getCurrentDirectory: () => system.getCurrentDirectory(),
1515
getNewLine: () => system.newLine,
1616
getCanonicalFileName: createGetCanonicalFileName(system.useCaseSensitiveFileNames),

0 commit comments

Comments
 (0)