3 ms·
As someone who swore by Typescript over Javascript, it's an annoyance. Dialyzer type specs create more pain than they're worth imho and you rarely get useful au
by dns_snek 4y ago
As someone who swore by Typescript over Javascript, it's an annoyance. Dialyzer type specs create more pain than they're worth imho and you rarely get useful autocomplete in return since Elixir IDEs (VS Code/Jetbrains + FOSS plugins) aren't as advanced as they are with Typescript.
As another comment has mentioned, what works for me is defining structs for more complex parameters and using them like so:
def some_function(param1, param2, bag_of_options = %BagOfOptions{}) do
With this you'll get autocomplete when you type `bag_of_options.`, a compilation warning* [1] if you try to access properties of `bag_of_options` that don't exist, and it's going to raise an error if you run the code and try to call the function with anything other than a %BagOfOptions{} struct.
TypedStruct library is particularly useful when defining structs, allowing you to easily define and document fields, assign them Dyalizer types and set their default values.
This is good enough for me not to significantly hinder my productivity, but YMMV.
[1] Compilation warnings can be treated as errors using --warnings-as-errors, I use it for all production builds