chulkilee / ex_force

A Salesforce REST API wrapper for Elixir
https://hex.pm/packages/ex_force
MIT License
38 stars 28 forks source link

Fix the typespec for the 'build_client' function #57

Closed LeoLeiteSC closed 3 years ago

LeoLeiteSC commented 3 years ago

I'm using the main branch since the hmac is deprecated in Erlang 24, and I found a bug when building my own build_client function. It's possible to see this bug mainly in the Dialyzer:

lib/.../adapters/tesla/tesla.ex:24:callback_type_mismatch
Type mismatch for @callback build_client/1 in ExForce.Client behaviour.
Expected type:
atom()
Actual type:
%Tesla.Client{
  :adapter => nil | {:fn, (... -> any)},
  :fun => nil,
  :post => [{_, _} | {_, _, _}],
  :pre => [{_, _} | {_, _, _}]
}

The problem is a recent change that modify the type of the build_client function to be module, but Elixir internally sees this type as an atom: https://hexdocs.pm/elixir/1.12/typespecs.html#built-in-types

I think the best solution is modify this type to any again.