fixes for TypeScript 4.4.x

closes #1386
This commit is contained in:
Damien Elmes 2021-09-23 09:51:11 +10:00
parent 94c4f99343
commit 82f1cda09a
2 changed files with 14 additions and 2 deletions

7
ts/lib/shadow-dom.d.ts vendored Normal file
View file

@ -0,0 +1,7 @@
export {};
declare global {
interface DocumentOrShadowRoot {
getSelection(): Selection | null;
}
}

View file

@ -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 `<div>Invalid ${type} on card: ${errorMessage}\n${errorStack}</div>`.replace(
/\n/g,
"<br>"