Skip to content

Precise typing of embeds #11

Description

Currently strukt typing embeds_one :foo, Foo's type as Foo.t(), embeds_many :foos, Foo as [Foo.t()]:

strukt/lib/typespec.ex

Lines 72 to 77 in 2b6c643

|> Enum.map(fn
{name, %{type: :embeds_one, value_type: type}} ->
{name, compose_call(type, :t, [])}
{name, %{type: :embeds_many, value_type: type}} ->
{name, List.wrap(compose_call(type, :t, []))}

it couldn't handle situations like

  • :foo field could be null which type should be Foo.t() | nil,
  • :foos could be nil, but element couldn't: [Foo.t()] | nil
  • :foos could be nil, element's could be nil too: nil | [Foo.t() | nil]

any idea for handle these cases?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions