eslint problems fixed, now theres only 850 ts ones to go
diff --git a/src/utils/getEmojiByName.ts b/src/utils/getEmojiByName.ts
index 63b2042..c0a43cb 100644
--- a/src/utils/getEmojiByName.ts
+++ b/src/utils/getEmojiByName.ts
@@ -1,10 +1,21 @@
import emojis from "../config/emojis.json" assert {type: "json"};
+interface EmojisIndex {
+ [key: string]: string | EmojisIndex | EmojisIndex[];
+}
+
function getEmojiByName(name: string, format?: string): string {
const split = name.split(".");
- let id = emojis;
+ let id: string | EmojisIndex | EmojisIndex[] | undefined = emojis;
split.forEach(part => {
- id = id[part];
+ if (typeof id === "string" || id === undefined) {
+ throw new Error(`Emoji ${name} not found`);
+ }
+ if (Array.isArray(id)) {
+ id = id[parseInt(part)];
+ } else {
+ id = id[part];
+ }
});
if ( format === "id" ) {
if (id === undefined) return "0";