From 1b9ab04d4b4694eb32402daf83f8df5f13df23ec Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 28 Feb 2020 23:56:17 +0200 Subject: vscode: migrate to more type-safe assert impl --- editors/code/src/util.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'editors/code/src/util.ts') diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 68c2a94d0..acf78898b 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -1,22 +1,26 @@ import * as lc from "vscode-languageclient"; import * as vscode from "vscode"; +import { strict as nodeAssert } from "assert"; -let enabled: boolean = false; +export function assert(condition: unknown, explanation: string): asserts condition { + nodeAssert(condition, explanation); +} export const log = { + enabled: true, debug(message?: any, ...optionalParams: any[]): void { - if (!enabled) return; + if (!log.enabled) return; // eslint-disable-next-line no-console console.log(message, ...optionalParams); }, error(message?: any, ...optionalParams: any[]): void { - if (!enabled) return; + if (!log.enabled) return; debugger; // eslint-disable-next-line no-console console.error(message, ...optionalParams); }, setEnabled(yes: boolean): void { - enabled = yes; + log.enabled = yes; } }; -- cgit v1.2.3