Skip to content

Commit f0c67c1

Browse files
committed
Imporved error instantiation
1 parent fcfb680 commit f0c67c1

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

src/Compiler.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,20 @@ export function watchWithOptions(fileNames: string[], options: CompilerOptions):
4040
);
4141
}
4242

43-
const errorDiagnostic: ts.Diagnostic = {
44-
category: undefined,
45-
code: 0,
46-
file: undefined,
47-
length: 0,
48-
messageText: "",
49-
start: 0,
50-
};
51-
5243
host.afterProgramCreate = program => {
5344
const status = emitFilesAndReportErrors(program.getProgram());
54-
let messageText = "Found 0 errors. Watching for file changes.";
55-
let code = 6194;
45+
const errorDiagnostic: ts.Diagnostic = {
46+
category: undefined,
47+
code: 6194,
48+
file: undefined,
49+
length: 0,
50+
messageText: "Found 0 errors. Watching for file changes.",
51+
start: 0,
52+
};
5653
if (status !== 0) {
57-
messageText = "Found Errors. Watching for file changes.";
58-
code = 6193;
54+
errorDiagnostic.messageText = "Found Errors. Watching for file changes.";
55+
errorDiagnostic.code = 6193;
5956
}
60-
errorDiagnostic.messageText = messageText;
61-
errorDiagnostic.code = code;
6257
host.onWatchStatusChange(
6358
errorDiagnostic,
6459
host.getNewLine(),
@@ -111,7 +106,7 @@ function emitFilesAndReportErrors(program: ts.Program): number {
111106
let outPath = sourceFile.fileName;
112107
if (options.outDir !== options.rootDir) {
113108
const relativeSourcePath = path.resolve(sourceFile.fileName)
114-
.replace(path.resolve(rootDir), "");
109+
.replace(path.resolve(rootDir), "");
115110
outPath = path.join(options.outDir, relativeSourcePath);
116111
}
117112

0 commit comments

Comments
 (0)