Skip to content

transition_to spec limits state to String type #82

@kyleboe

Description

@kyleboe

In the spec definition for transition_to it specifies String.t() as the next_state's type.

@spec transition_to(struct, module, String.t()) :: {:ok, struct} | {:error, String.t()}

I believe this is incorrect. An atom is used in examples & typespecs for the state argument(s). I also confirmed locally that using atom states does not cause any errors.

Should a typespec be added for state? Possibly something like so:

@typedoc """
A state should be a string or an atom. Whichever corresponds with the underlying state field on the given struct.
"""
@type state :: atom | String.t()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions