Skip to content

Commit 170456d

Browse files
committed
Appease typescript 5.3 https://stackoverflow.com/a/78681671
1 parent a96e390 commit 170456d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ You may also need to manually run the frontend linter. First, navigate to the `f
103103

104104
```bash
105105
pnpm run format
106+
pnpm run check
106107
```
107108

108109
### Assorted Development Helpers

frontend/src/lib/components/left-bar/Settings.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,21 @@
171171
}
172172
}))).filter((mod) => mod !== undefined);
173173
// Sort by Friendly Name
174+
// TODO Once we upgrade to Typescript 5.5 we don't need the non-null assertion operators https://stackoverflow.com/a/78681671
174175
modList.sort((a, b) => {
175-
const x = a.friendlyName.toLowerCase();
176-
const y = b.friendlyName.toLowerCase();
176+
const x = a!.friendlyName.toLowerCase();
177+
const y = b!.friendlyName.toLowerCase();
177178
return x.localeCompare(y);
178179
});
179180
// Get max lengths to use for padding
180-
const maxFriendlyNameLen = Math.max(...modList.map((mod) => mod.friendlyName.length));
181-
const maxModReferenceLen = Math.max(...modList.map((mod) => mod.modReference.length));
181+
const maxFriendlyNameLen = Math.max(...modList.map((mod) => mod!.friendlyName.length));
182+
const maxModReferenceLen = Math.max(...modList.map((mod) => mod!.modReference.length));
182183
// Create header and add all mods to string
183184
let modListString = `${'Mod Name'.padEnd(maxFriendlyNameLen + 1) + 'Mod Reference'.padEnd(maxModReferenceLen + 1)}Version\n`;
184185
modList.forEach((mod) => {
185-
mod.friendlyName = mod.friendlyName.padEnd(maxFriendlyNameLen, ' ');
186-
mod.modReference = mod.modReference.padEnd(maxModReferenceLen, ' ');
187-
modListString += `${mod.friendlyName} ${mod.modReference} ${mod.version}\n`;
186+
mod!.friendlyName = mod!.friendlyName.padEnd(maxFriendlyNameLen, ' ');
187+
mod!.modReference = mod!.modReference.padEnd(maxModReferenceLen, ' ');
188+
modListString += `${mod!.friendlyName} ${mod!.modReference} ${mod!.version}\n`;
188189
});
189190
const markdownCodeblockFence = '```';
190191
navigator.clipboard.writeText(`${markdownCodeblockFence}\n${modListString.trim()}\n${markdownCodeblockFence}`);
@@ -196,7 +197,7 @@
196197
}
197198
198199
// appease svelte "stores must be declared at the top of the file"
199-
function displayError(err: unknown) {
200+
function displayError(err: string) {
200201
$error = err;
201202
}
202203

0 commit comments

Comments
 (0)