From 6032c967ed7037a0026a99473d85e25044efd245 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 17 Feb 2024 18:45:50 +0100 Subject: [PATCH] chore: add proper types for wordset and section --- frontend/src/ts/test/test-logic.ts | 2 +- frontend/src/ts/types/types.d.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 8cc997f90..56fd00d8b 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -617,7 +617,7 @@ export async function addWord(): Promise { let wordCount = 0; for (let i = 0; i < section.words.length; i++) { - const word = section.words[i]; + const word = section.words[i] as string; if (wordCount >= Config.words && Config.mode === "words") { break; } diff --git a/frontend/src/ts/types/types.d.ts b/frontend/src/ts/types/types.d.ts index b6bc9b98e..fe64adfae 100644 --- a/frontend/src/ts/types/types.d.ts +++ b/frontend/src/ts/types/types.d.ts @@ -108,6 +108,20 @@ declare namespace MonkeyTypes { | "changesWordsFrequency" | `wordOrder:${FunboxWordOrder}`; + class Wordset { + public words: string[]; + public length: number; + constructor(words: string[]); + randomWord(mode: MonkeyTypes.FunboxWordsFrequency): string; + } + + class Section { + public title: string; + public author: string; + public words: string[]; + constructor(title: string, author: string, words: string[]); + } + type FunboxFunctions = { getWord?: (wordset?: Wordset, wordIndex?: number) => string; punctuateWord?: (word: string) => string;