From 6d6bc735e97a60bc239c079324a0699bbd0764ac Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 18 Jan 2020 11:12:11 +0200 Subject: [PATCH] Fix TS error with twemoji typings without dom lib Including the dom lib doesn't make much sense since we're not in a browser environment. While this solution isn't perfect either, I think it's more fitting. --- backend/src/plugins/Utility.ts | 8 ++++++++ backend/tsconfig.json | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/Utility.ts b/backend/src/plugins/Utility.ts index a3f7a39f..68ebf064 100644 --- a/backend/src/plugins/Utility.ts +++ b/backend/src/plugins/Utility.ts @@ -66,6 +66,14 @@ import fs from "fs"; import sharp from "sharp"; import twemoji from "twemoji"; +declare global { + // This is here so TypeScript doesn't give an error when importing twemoji + // since one of the signatures of twemoji.parse() takes an HTMLElement but + // we're not in a browser environment so including the DOM lib would not make + // sense + type HTMLElement = unknown; +} + import { Url, URL, URLSearchParams } from "url"; const ConfigSchema = t.type({ can_roles: t.boolean, diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 26db7ca1..84c78116 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -8,8 +8,7 @@ "emitDecoratorMetadata": true, "target": "es2018", "lib": [ - "esnext", - "DOM" + "esnext" ], "baseUrl": ".", "resolveJsonModule": true,