smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.64k stars 2.71k forks source link

Refactor types for Lowercase<string> #10377

Closed Zarel closed 4 days ago

Zarel commented 6 days ago

TypeScript 4.8+ supports Lowercase for lowercase strings, which isn't exactly what ID is, but can be used to type IDs in object keys and data entries that previously required string. I'm calling it IDEntry in places where it should be an ID but TypeScript doesn't support that.

Very conveniently, no additional casts will be needed when using ID where IDEntry is expected.

It's caught at least a few bugs, which is also why I'm PRing: I didn't write the code for the bugs it found, and don't know if it's the right way to fix them.

This ballooned into several other type refactors.

Zarel commented 6 days ago

Heh, refactors that touch data files:

image