dashbitco / nimble_options

A tiny library for validating and documenting high-level options. 💽
Apache License 2.0
507 stars 38 forks source link

option_schema doesn't support :map options #95

Closed dmaze closed 1 year ago

dmaze commented 2 years ago

Given this module:

defmodule Test do
  @options_schema NimbleOptions.new!(
    map: [type: :map]
  )
  @type option() :: unquote(NimbleOptions.option_typespec(@options_schema))
end

Loading this up in Visual Studio Code with ElixirLS produces a Dialyzer error

(CaseClauseError) no case clause matching: :map

Stacktrace:
  │ (nimble_options 0.5.0) lib/nimble_options/docs.ex:163: NimbleOptions.Docs.type_to_spec/1
  │ (nimble_options 0.5.0) lib/nimble_options/docs.ex:156: anonymous fn/1 in NimbleOptions.Docs.schema_to_spec/1
  │ (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
  │ (nimble_options 0.5.0) lib/nimble_options/docs.ex:155: NimbleOptions.Docs.schema_to_spec/1
  │ test.ex:5: (module)

It looks like NimbleOptions.Docs.type_to_spec/1 doesn't support :map or {:map, key_type, value_type}.

josevalim commented 2 years ago

Ah, can you please send a PR?