From a34c040acd2b0875bf35988666636cec2d464454 Mon Sep 17 00:00:00 2001 From: xenticore Date: Wed, 30 Apr 2025 18:33:17 -0400 Subject: [PATCH] refactor: correct typing of `getKeyByValue` --- src/content/content.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/content/content.ts b/src/content/content.ts index 8629543..d5b8775 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -22,8 +22,13 @@ const excludedQualities = new Set([ ]); // Helper functions -function getKeyByValue(object: any, value: string) { - return Object.keys(object).find(key => object[key] === value); +function getKeyByValue(obj: Record, value: V): K | undefined { + for (const [key, val] of Object.entries(obj)) { + if (val === value) { + return key as unknown as K; + } + } + return undefined; } // Main function