defmodule Hello.Database.Template do
schema "templates" do
field(:name, :string)
field(:description, :string)
end
end
and when I call it in another module e.g.
defmodule Hello.Worker.SomethingElse do
alias Hello.Database.Template
@spec something(map()) :: Template.t()
def something(map) do
end
end
Dialyzer will complain that there is no Template.t() . Where would be the best place to define this type? would this go inside of Hello.Database.Template and look something like this?
defmodule Hello.Database.Template do
@type %__MODULE__{
name: string,
description: string
}
schema "templates" do
field(:name, :string)
field(:description, :string)
end
end
It just felt a little weird to me to put the schema and the type at the same place but I could not figure out where it would live a bit better. I’ll add it into the schema file. Thank you!
I’m hoping that it won’t be necessary in the long term. For things where I can’t rely on the compiler, I imagine it might look something like the 2nd but I think it depends on what the new type syntax looks like when it’s rolled out.