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?
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
@fielda 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?