In ex_money, dialyzer shows me the error: "Unknown type: Money.Ecto.Composite.Type.t/0."

Dialyzer shows me this error when I run mix dialyzer.

Unknown type: Money.Ecto.Composite.Type.t/0.

This is my schema:

typed_schema "store_item_prices" do
    field(:price, Money.Ecto.Composite.Type)

How do I fix this dialyzer error?

The fix is really simple, but hard as heck to find. Hope this helps!

typed_schema "store_item_prices" do
    field(:price, Money.Ecto.Composite.Type) :: Money.t()

I think the primary issue is that there is no such type as Money.Ecto.Composite.Type.t/0.

I can add one but I’m not actually sure how to type a parameterized type. I’ll look into it but I’m definitely open to advice and guidance.

1 Like

I think what you are doing is already the best approach. The native Ecto.schema/2 macro does not require a typespec on a field and there is no practical definition that I can see that makes sense to type Money.Ecto.Composite.Type since it the function signatures for load, dump and cast can take many forms.

Very open to alternative opinions, improved docs or other suggestions.

1 Like

Thanks @kip !