summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-05-03 01:30:03 +0200
committerGitHub <noreply@github.com>2021-05-02 19:30:03 -0400
commitea917384feb1c800438d13dddac9ee977d2c47fe (patch)
treee3d5069ac4f96713c98519853cfe25e93c32f883 /cli/tsc
parentc9ac851b9005e5a1e90016e52b3a10dd1f1012b7 (diff)
refactor(core): convert core.print() to a builtin op (#10436)
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/99_main_compiler.js11
-rw-r--r--cli/tsc/compiler.d.ts2
2 files changed, 7 insertions, 6 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index f944b21b8..b4626374d 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -34,15 +34,16 @@ delete Object.prototype.__proto__;
}
}
+ function printStderr(msg) {
+ core.print(msg, true);
+ }
+
function debug(...args) {
if (logDebug) {
const stringifiedArgs = args.map((arg) =>
typeof arg === "string" ? arg : JSON.stringify(arg)
).join(" ");
- // 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);
+ printStderr(`DEBUG ${logSource} - ${stringifiedArgs}\n`);
}
}
@@ -52,7 +53,7 @@ delete Object.prototype.__proto__;
? String(arg)
: JSON.stringify(arg)
).join(" ");
- core.print(`ERROR ${logSource} = ${stringifiedArgs}\n`, 1);
+ printStderr(`ERROR ${logSource} = ${stringifiedArgs}\n`);
}
class AssertionError extends Error {
diff --git a/cli/tsc/compiler.d.ts b/cli/tsc/compiler.d.ts
index 13e6564b4..e5ce12cd3 100644
--- a/cli/tsc/compiler.d.ts
+++ b/cli/tsc/compiler.d.ts
@@ -36,7 +36,7 @@ declare global {
// deno-lint-ignore no-explicit-any
opSync<T>(name: string, params: T): any;
ops(): void;
- print(msg: string, code?: number): void;
+ print(msg: string, stderr: bool): void;
registerErrorClass(
name: string,
Ctor: typeof Error,