Skip to content

@pkmn/sets: functionality of Sets functions don't match types #37

@Gudine

Description

@Gudine

Describe the bug:

The return value of some of the functions in @pkmn/sets don't match the types assigned to them. Specifically:

  • Sets.unpackSet's return potentially lacks two properties from PokemonSet: gender and level;
  • Sets.importSet returns undefined when given a string containing only spaces;
  • Sets.canonicalize throws when given a PokemonSet partial that doesn't have species or moves — the latter in particular can happen when giving it the output of Sets.importSet.

Example:

const set1 = Sets.unpackSet("Espeon|||-||||||||");

console.log(set1.gender, set1.level);
// undefined, undefined

const set2 = Sets.importSet("");

console.log(set2);
// undefined

Sets.canonicalize(Sets.importSet("Tangrowth"), Dex);
// Uncaught TypeError: s.moves is not iterable

Expected behavior:

The functions' parameter and return types should match their implementations.

Additional context:

I'd be willing to open a PR to fix the issues, but I'd have to know whether the types or the implementations should be changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions