View Source Credo.Check.Warning.SpecWithStruct (Credo v1.7.5)


This check is enabled by default.

Learn how to disable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.


Structs create compile-time dependencies between modules. Using a struct in a spec will cause the module to be recompiled whenever the struct's module changes.

It is preferable to define and use MyModule.t() instead of %MyModule{} in specs.


# preferred
@spec a_function(MyModule.t()) :: any

# NOT preferred
@spec a_function(%MyModule{}) :: any

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.