Update TypeScript config (and fix vitamin type)#222
Update TypeScript config (and fix vitamin type)#222Hyperseeker wants to merge 5 commits intonornagon:mainfrom
Conversation
| "isolatedModules": true, | ||
| "strict": true, | ||
| "ignoreDeprecations": "5.0" | ||
| "noEmit": true |
There was a problem hiding this comment.
why these changes? noEmit: true seems in particular an odd change here.
There was a problem hiding this comment.
noEmit is to make TypeScript (correctly) believe it's only there for typechecking. You already bundle everything with Vite. TypeScript's had an issue with an .mjs file, which was considered both a source and a target (because it's a JS file, not a TS file). noEmit makes sure TypeScript doesn't have to think about these things.
ignoreDeprecations was the band-aid I mentioned in the PR body: it meant being able to stick to TypeScript v4 for longer, despite it being not the best idea. Removing it means you have to face the changes from v5 (which is about time, since v6 has already been published in beta, and v7 is available in the preview). This is also why I had to make the vitamin changes, which were otherwise hidden by some of the looser handling.
Everything else naturally propagates to the project from Svelte's TypeScript config.
|
Updated |
Overview
This PR brings the app's TypeScript version to the latest stable value, and updates the associated packages to enable this. TypeScript was bumped because my IDE complained about outdated options and deprecations; the other packages were bumped to bring them in line with the expected TS version (all updated packages now use at least TS v5), as they were causing other issues with the config.
The overall impact of this PR is: it brings the codebase closer to modern standards, while eliminating outdated issues (and the bandaids that kept everything from falling apart), thus improving the DX for future developers and maintainers.
Secondary changes
By way of fixing other resulting issues, this PR also updates the type of
Vitamin.rateto bring it in line with the code, rather than make the code follow the types. I believe earlier implementations of vitamins used numerical values, rather than quantity strings, for duration. The changes in this PR enable further support for very old versions of the game in HHG. (Whether this is really necessary is worth discussing; I'm open to reverting this change.)It's also worth noting that in the current codebase of DDA,
ratehas a default value of"0 m"; this would make it optional in TypeScript. As such, even if supporting numerical vitamin rates is not a priority,rateshould be marked as optional. All current vitamins haveratepresent and a quantity string, but that doesn't mean the value will always be present for all sources (including any potential future support for mods).Aside from this,
Vitamin.svelteandComestibleInfo.sveltesaw changes to both handle the updated type and guard against the possible value of 0 (and the resulting displayed value ofInfinity).Testing
Ran the dev server locally, searched a few things using default parameters (latest experimental, ASCII tileset, English language). Did not run the tests because they would take 10+ mins per, and I believe the manual testing (see below) should suffice.
Note that it's basically impossible to find these in the UI: they don't show up in default search, and are only reacheable through their associated items or by manipulating the URL. I've only tested the ones with unique values (most vitamins have decay rates of 15 m or 1 h).
calcium: decay rate of–1 / 15 mvit_betablocker: decay rate of–1 / 100 sbad_food: decay rate of–1 / 4 hblood: generation rate of1 / 6 s