Skip to content

Commit e226389

Browse files
committed
chore: add type hints
1 parent 9b86659 commit e226389

File tree

5 files changed

+115
-97
lines changed

5 files changed

+115
-97
lines changed

arbys.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ declare let currentHour: number;
2020
const days = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ];
2121
const months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
2222

23-
function loc(key)
23+
function loc(key: string): string
2424
{
2525
return dict[key] ?? key;
2626
}
2727

28-
function totwo(num)
29-
{
30-
if (num < 10)
31-
{
32-
return "0" + num;
33-
}
34-
return num;
35-
}
28+
function totwo(num: number): string
29+
{
30+
if (num < 10)
31+
{
32+
return "0" + num;
33+
}
34+
return num.toString();
35+
}
3636

37-
function formattz(offset)
37+
function formattz(offset: number): string
3838
{
3939
if (offset == 0)
4040
{
@@ -49,7 +49,7 @@ function formattz(offset)
4949
}
5050
document.getElementById("local-time-option").textContent += " (" + formattz(new Date().getTimezoneOffset()) + ")";
5151

52-
function formathour(hour)
52+
function formathour(hour: number): string
5353
{
5454
switch ((document.getElementById("select-hourfmt") as HTMLSelectElement).value)
5555
{
@@ -111,7 +111,7 @@ Promise.all([
111111
onLanguageUpdate();
112112
});
113113

114-
function updateFilterNamesForLocale()
114+
function updateFilterNamesForLocale(): void
115115
{
116116
document.querySelector("label[for=filter-MT_SURVIVAL]").textContent = toTitleCase(dict["/Lotus/Language/Missions/MissionName_Survival"]);
117117
document.querySelector("label[for=filter-MT_DEFENSE]").textContent = toTitleCase(dict["/Lotus/Language/Missions/MissionName_Defense"]);
@@ -132,7 +132,7 @@ function updateFilterNamesForLocale()
132132
document.querySelector("label[for=filter-FC_MITW]").textContent = dict["/Lotus/Language/Game/Faction_MITW"];
133133
}
134134

135-
function updateLog()
135+
function updateLog(): void
136136
{
137137
console.time("updateLog");
138138

@@ -281,7 +281,7 @@ function updateLog()
281281
console.timeEnd("updateLog");
282282
}
283283

284-
function saveSettings()
284+
function saveSettings(): void
285285
{
286286
let hash = "days=" + encodeURIComponent((document.getElementById("select-days") as HTMLSelectElement).value)
287287
+ "&tz=" + encodeURIComponent((document.getElementById("select-tz") as HTMLSelectElement).value)

index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if (params.has("q"))
6161
document.getElementById("results-status").textContent = "Loading...";
6262
}
6363

64-
(document.getElementById("query") as HTMLInputElement).oninput = function(this: HTMLInputElement)
64+
(document.getElementById("query") as HTMLInputElement).oninput = function(this: HTMLInputElement): void
6565
{
6666
if (this.value == "")
6767
{
@@ -183,7 +183,7 @@ Promise.all([
183183
doQuery((document.getElementById("query") as HTMLInputElement).value);
184184
}
185185

186-
document.getElementById("query").oninput = function(this: HTMLInputElement)
186+
document.getElementById("query").oninput = function(this: HTMLInputElement): void
187187
{
188188
if (this.value == "")
189189
{
@@ -212,7 +212,7 @@ Promise.all([
212212
};
213213
});
214214

215-
function updateMissionDeckNames()
215+
function updateMissionDeckNames(): void
216216
{
217217
window.missionDeckNames = {
218218
"/Lotus/Types/Game/MissionDecks/SortieRewards": ["Sortie"],
@@ -251,7 +251,7 @@ function updateMissionDeckNames()
251251
});
252252
}
253253

254-
function doQuery(query: string)
254+
function doQuery(query: string): void
255255
{
256256
console.time("Input to language tags");
257257
let results = getDictEntriesFromQuery(query).reduce((arr, [key, value]) =>
@@ -768,8 +768,8 @@ function getDictEntriesFromQuery(query: string): [string, string][]
768768
});
769769
}
770770

771-
function resolveTagsToUses(results)
772-
{
771+
function resolveTagsToUses(results: { type: string; key: string; value: any }[]): { type: string; key: string; value: any }[]
772+
{
773773
const res = [];
774774
outer: for (const result of results)
775775
{
@@ -790,7 +790,7 @@ function resolveTagsToUses(results)
790790
return res;
791791
}
792792

793-
function addUniqueNameResults(res, query)
793+
function addUniqueNameResults(res: { type: string; key: string; value: any }[], query: string): void
794794
{
795795
query = query.toLowerCase();
796796
for (const [type, entries] of Object.entries(window.meta_entries))

0 commit comments

Comments
 (0)