Qqwy / elixir-type_check

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Turn off (or alter other options of) TypeCheck in dependencies

Qqwy opened this issue · comments

When TypeCheck is in use in a dependency of your application, you might want to alter how it works.
Maybe there are extra overrides you want to provide, or maybe you want to enable debug mode, or maybe turn it off all-together in a particular environment.

One approach to do this might be to have TypeCheck.Options.new look at Application.compile_env(Application.get_application(caller), :type_check).

I was thinking about adding TypeCheck to a library of mine that is a dependency of our application and wondered about this. I was planning to probably set enable_runtime_checks to false in production, but it would be nice if that was configurable at some point given our app may want to reference dependency @type!s. How/where might you see the actual configuration being done?

Would it potentially be something in config.exs like?...

  config :type_check,
  dependencies: %{
    # same options available to `use TypeCheck`
    some_dep_1: [enable_runtime_checks: ...
    some_dep_2: [...
  }

I was thinking:

config :your_dependency_name, :type_check,
  # same options available to `use TypeCheck`
  enable_runtime_checks: false,
  # etc.

This approach is used by other libraries as well. Check for instance how Logger manages its (OTP-)application-specific logging settings.

Ah, that looks like a nice way to configure.