chore: add proper types for wordset and section

This commit is contained in:
Miodec 2024-02-17 18:45:50 +01:00
parent aec04bc8cc
commit 6032c967ed
2 changed files with 15 additions and 1 deletions

View file

@ -617,7 +617,7 @@ export async function addWord(): Promise<void> {
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;
}

View file

@ -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;