From 82f1cda09a815843f53ad849c52e19007e9f3d09 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 23 Sep 2021 09:51:11 +1000 Subject: [PATCH] fixes for TypeScript 4.4.x closes #1386 --- ts/lib/shadow-dom.d.ts | 7 +++++++ ts/reviewer/index.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 ts/lib/shadow-dom.d.ts diff --git a/ts/lib/shadow-dom.d.ts b/ts/lib/shadow-dom.d.ts new file mode 100644 index 000000000..45ba96990 --- /dev/null +++ b/ts/lib/shadow-dom.d.ts @@ -0,0 +1,7 @@ +export {}; + +declare global { + interface DocumentOrShadowRoot { + getSelection(): Selection | null; + } +} diff --git a/ts/reviewer/index.ts b/ts/reviewer/index.ts index 7381a865c..3b69aafa0 100644 --- a/ts/reviewer/index.ts +++ b/ts/reviewer/index.ts @@ -80,9 +80,14 @@ function setInnerHTML(element: Element, html: string): void { const renderError = (type: string) => - (error: Error): string => { + (error: unknown): string => { const errorMessage = String(error).substring(0, 2000); - const errorStack = String(error.stack).substring(0, 2000); + let errorStack: string; + if (error instanceof Error) { + errorStack = String(error.stack).substring(0, 2000); + } else { + errorStack = ""; + } return `
Invalid ${type} on card: ${errorMessage}\n${errorStack}
`.replace( /\n/g, "
"