Skip to content

Split read/write types for @fields #1129

Description

@justarandomgeek

In Factorio's API (and presumably many others?) we have a large number of API objects with properties that accept assignment from a wide union of types but only ever return one specific member of that union when read. In particular, there are many that accept writing nil to reset them to default states, but will never read as nil.

Unfortunately, since we can only give the @field a single type, we currently have to give it the wider of the two, which results in many spurious warnings about nil checks and type tests on values read from these affected properties.

Would it be possible to have separate types for @fields to validate against for read/write access?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions