TypeCheck - Fast and flexible runtime type-checking for your Elixir projects

It seems like perhaps TypeCheck is not even loaded. Is it installed via mix? In a Phoenix project?

Other than that, the syntax you have here should work. You don’t even need the argument names (e.g. arg1 :: if you don’t want them. I don’t include them.

However, while TypeCheck supports most of the builtin types, it does not support remote types like String.t(). There is an issue at Overrides for builtin remote types like String.t,Enum.t, Range.t, MapSet.t etc. · Issue #5 · Qqwy/elixir-type_check · GitHub

You could use binary in place of that. I personally use this custom placeholder type for strings:

@type! utf8_binary :: binary

Once String.t() is supported I’ll probably replace references to utf8_binary with that or continue to use utf8_binary and replace binary with String.t().

1 Like