summaryrefslogtreecommitdiff
path: root/cli/tsc/99_main_compiler.js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc/99_main_compiler.js')
-rw-r--r--cli/tsc/99_main_compiler.js43
1 files changed, 25 insertions, 18 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index ddbb8fcac..d65aaa4c1 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -31,10 +31,22 @@ delete Object.prototype.__proto__;
const stringifiedArgs = args.map((arg) =>
typeof arg === "string" ? arg : JSON.stringify(arg)
).join(" ");
- core.print(`DEBUG ${logSource} - ${stringifiedArgs}\n`);
+ // adding a non-zero integer value to the end of the debug string causes
+ // the message to be printed to stderr instead of stdout, which is better
+ // aligned to the behaviour of debug messages
+ core.print(`DEBUG ${logSource} - ${stringifiedArgs}\n`, 1);
}
}
+ function error(...args) {
+ const stringifiedArgs = args.map((arg) =>
+ typeof arg === "string" || arg instanceof Error
+ ? String(arg)
+ : JSON.stringify(arg)
+ ).join(" ");
+ core.print(`ERROR ${logSource} = ${stringifiedArgs}\n`, 1);
+ }
+
class AssertionError extends Error {
constructor(msg) {
super(msg);
@@ -497,23 +509,18 @@ delete Object.prototype.__proto__;
);
return respond(id, sourceFile && sourceFile.text);
}
- case "getSemanticDiagnostics": {
- const diagnostics = languageService.getSemanticDiagnostics(
- request.specifier,
- ).filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code));
- return respond(id, fromTypeScriptDiagnostic(diagnostics));
- }
- case "getSuggestionDiagnostics": {
- const diagnostics = languageService.getSuggestionDiagnostics(
- request.specifier,
- ).filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code));
- return respond(id, fromTypeScriptDiagnostic(diagnostics));
- }
- case "getSyntacticDiagnostics": {
- const diagnostics = languageService.getSyntacticDiagnostics(
- request.specifier,
- ).filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code));
- return respond(id, fromTypeScriptDiagnostic(diagnostics));
+ case "getDiagnostics": {
+ try {
+ const diagnostics = [
+ ...languageService.getSemanticDiagnostics(request.specifier),
+ ...languageService.getSuggestionDiagnostics(request.specifier),
+ ...languageService.getSyntacticDiagnostics(request.specifier),
+ ].filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code));
+ return respond(id, fromTypeScriptDiagnostic(diagnostics));
+ } catch (e) {
+ error(e);
+ return respond(id, []);
+ }
}
case "getQuickInfo": {
return respond(