From 83f53c6455bacbe62998ebc56199d0c2d7f1a870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 25 Sep 2020 14:04:51 +0200 Subject: refactor: remove tsc/40_error_stack.js (#7673) This commit removes cli/tsc/40_error_stack.js as it is not needed in TSC host. All errors originating in TSC are terminal and don't require source mapping hence we can rely on default stack traces provided by deno_core. Additionally tsc/06_util.js was removed and its code moved to tsc/99_main_compiler.js --- cli/tsc/99_main_compiler.js | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'cli/tsc/99_main_compiler.js') diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 94a08e6ab..d06912b1f 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -18,11 +18,42 @@ delete Object.prototype.__proto__; ((window) => { const core = window.Deno.core; - const { assert, log, notImplemented } = window.__bootstrap.util; - const util = window.__bootstrap.util; - const errorStack = window.__bootstrap.errorStack; const errors = window.__bootstrap.errors.errors; + let logDebug = false; + let logSource = "JS"; + + function setLogDebug(debug, source) { + logDebug = debug; + if (source) { + logSource = source; + } + } + + function log(...args) { + if (logDebug) { + const stringifiedArgs = args.map(JSON.stringify).join(" "); + core.print(`DEBUG ${logSource} - ${stringifiedArgs}\n`); + } + } + + class AssertionError extends Error { + constructor(msg) { + super(msg); + this.name = "AssertionError"; + } + } + + function assert(cond, msg = "Assertion failed.") { + if (!cond) { + throw new AssertionError(msg); + } + } + + function notImplemented() { + throw new Error("not implemented"); + } + /** * @param {import("../dts/typescript").DiagnosticRelatedInformation} diagnostic */ @@ -1303,8 +1334,7 @@ delete Object.prototype.__proto__; // are ready. The response should be a `StartRes` message containing the CLI // args and other info. const s = core.jsonOpSync("op_start"); - util.setLogDebug(s.debugFlag, source); - errorStack.setPrepareStackTrace(Error); + setLogDebug(s.debugFlag, source); return s; } -- cgit v1.2.3