Reputation: 17574
I have a small app using Elixir Desktop. This app works relatively well and launches without issues:
https://github.com/Fl4m3Ph03n1x/market_manager/tree/master/apps/web_interface
However, I have dialyzer complaining about types. I am not sure if this is a false positive, or if I am doing something wrong.
I have a MenuBar
in my application with some basic functionality. This MenuBar
is as far as I understand, a Phoenix LiveView component (because it has a mount
and a render
functions). So this code should look familiar for most users of Phoenix and LiveView:
defmodule WebInterface.Live.MenuBar do
@moduledoc """
Menubar that is shown as part of the main Window on Windows/Linux. In
MacOS this Menubar appears at the very top of the screen.
"""
use Desktop.Menu
alias Desktop.{Menu, Window}
@impl Menu
def render(assigns) do
~H"""
<menubar>
<menu label="File">
<hr/>
<item onclick="quit">Quit</item>
</menu>
</menubar>
"""
end
@impl Menu
def handle_event("quit", menu) do
Window.quit()
{:noreply, menu}
end
@impl Menu
def mount(menu), do: {:ok, menu}
@impl Menu
def handle_info(:changed, menu), do: {:noreply, menu}
end
The issue here is that Dialyzer is complaining about my render function:
Type mismatch for @callback render/1 in Desktop.Menu behaviour.
Expected type:
binary()
Actual type:
%Phoenix.LiveView.Rendered{
:dynamic => (_ -> []),
:fingerprint => 15_721_876_439_225_774_806_119_511_245_371_375_581,
:root => true,
:static => [<<_::1480>>, ...]
}
It says it expects a String instead of an H
sigil. Which is confusing to me, because the latest version does support this sigil.
So the question arises. What am I doing wrong and how can I fix this?
Upvotes: 2
Views: 44
Reputation: 17574
Turns out this was a bug from the library.
The fix is already in master as my PR was accepted: https://github.com/elixir-desktop/desktop/issues/17
Upvotes: 1