Fetching defined types in compile time

Guys, I have a library that contains a macro that defines a @type t only if it is not defined.

In order to check if the type was already defined at compile time I was doing a Module.get_attribute(SomeModule, :type) and checking if any of it was a :t.

In order to do that in 1.6.X I used this code exchema/lib/exchema/notation/typespec.ex at master · bamorim/exchema · GitHub

However, it is breaking on 1.7.X because Module.get_attribute(SomeModule, :type) now returns nil (it was running on a before_compile macro).

What is an alternative way to get the defined typespecs?

Try:

Module.defines_type?({:t, 0})

Thanks! It worked