News for hackers. Stuff that matters.
Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route... by dns_snek on Monday March 06, 2023 @07:23AM (#35040179)
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 error 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.

There are no comments on this comment yet.