Let’s say I have a map with required and optional keys. I’d like to document both, but based on the docs it seems like you can’t denote a specific key is optional. Where else do people document these optional keys?
With that example in mind, how do I specify in the @type params declaration that :bar is optional? Just leave it out and document its optionality in the @doc?
Since I have your attention () is there a way to specify something is required if another key is not present? In this case, you can either have a :counterparty_id or several :receiver_* pairs.
A potential stumbling block: even though the keys look like atoms, you can’t mix the x: and => when using optional. I assume this is because optional(:bar) resolves to a non-atom type.
The syntax sugar for keyword lists as well as for atom keys in maps is only allowed trailing to elements not using the syntax sugar within the same map/list. Though I‘m not sure if the same does work in typespecs.