This PR makes the struct type itself transparent while keeping its fields opaque so that functions operating on Phoenix.LiveView.JS.t can be properly specced. Otherwise, speccing the CoreComponents JS functions as such:
The @spec for WebWeb.CoreComponents.show/1 has an opaque
subtype Phoenix.LiveView.JS.t() which is violated by the success typing.
Success typing:
(_) :: %Phoenix.LiveView.JS{:ops => [any(), ...], _ => _}
This change also refactors usage of the struct update syntax in put_op to use Kernel.struct!/2, which appears to be necessary otherwise Dialyzer becomes convinced that the return type of functions using it is:
Phoenix.LiveView.JS.t
is already exposed as a struct by theCoreComponents
generator: https://github.com/phoenixframework/phoenix/blob/2e06455a4041965da133cd23a650245f53d6800c/priv/templates/phx.gen.live/core_components.ex#L602.This PR makes the struct type itself transparent while keeping its fields opaque so that functions operating on
Phoenix.LiveView.JS.t
can be properly specced. Otherwise, speccing theCoreComponents
JS functions as such:causes the following Dialyzer error:
This change also refactors usage of the struct update syntax in
put_op
to useKernel.struct!/2
, which appears to be necessary otherwise Dialyzer becomes convinced that the return type of functions using it is:My apologies if some or all of this is a Dialyzer or Dialyxir bug, or if the proper spec for functions like
CoreComponents.show/1
is something else.