I don't know why the compiler requires the port keyword to be present in modules to be present (and inversely to be absent when none are defined), but I think the formatter would be a great place to fix this issue automatically.
The idea would basically be to automatically add or remove the port keyword based on the presence of ports in the file. This would remove the one feedback cycle with the compiler and the need to resolve this manually.
Examples
port module A exposing (..)
a = 1
-->
module A exposing (..)
a = 1
module A exposing (..)
port toJS : String -> Cmd msg
-->
port module A exposing (..)
port toJS : String -> Cmd msg
I don't know why the compiler requires the
portkeyword to be present in modules to be present (and inversely to be absent when none are defined), but I think the formatter would be a great place to fix this issue automatically.The idea would basically be to automatically add or remove the
portkeyword based on the presence of ports in the file. This would remove the one feedback cycle with the compiler and the need to resolve this manually.Examples