diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index c0ca9bf4b62..c9d49f29440 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -68,10 +68,7 @@ export const normalForm: Species[] = [ * @param species The species to fetch * @returns The associated {@linkcode PokemonSpecies} object */ -export function getPokemonSpecies(species: Species | Species[] | undefined): PokemonSpecies { - if (!species) { - throw new Error("`species` must not be undefined in `getPokemonSpecies()`"); - } +export function getPokemonSpecies(species: Species | Species[]): PokemonSpecies { // If a special pool (named trainers) is used here it CAN happen that they have a array as species (which means choose one of those two). So we catch that with this code block if (Array.isArray(species)) { // Pick a random species from the list @@ -914,7 +911,8 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali for (const weight of evolutionPool.keys()) { if (randValue < weight) { - return getPokemonSpecies(evolutionPool.get(weight)).getSpeciesForLevel(level, true, forTrainer, strength, currentWave); + // TODO: this entire function is dumb and should be changed, adding a `!` here for now until then + return getPokemonSpecies(evolutionPool.get(weight)!).getSpeciesForLevel(level, true, forTrainer, strength, currentWave); } } diff --git a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts index ab50666ab3d..1bdc45348d6 100644 --- a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts +++ b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts @@ -116,7 +116,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty); const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]; - const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId; + const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId!; await runMysteryEncounterToEnd(game, 1, undefined, true); @@ -143,7 +143,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty); const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]; - const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId; + const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId!; await runMysteryEncounterToEnd(game, 1, undefined, true);