-
-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Expected Behavior
I would like to be warned that an "in port" would be stripped if no subscription is implemented.
Current Behavior
port module Main exposing (..)
-- Define an inPort (but no implementation yet)
port inPort : (String -> msg) -> Sub msg
subscriptions : Model -> Sub Msg
subscriptions _ =
Sub.none -- inPort is never subscribed toCurrently the result of the elm compiler is to strip this port as it is never used in the Elm code, and when we are trying to send a message to the port app.ports.inPort.send("Hello"); we will get a runtime exception. The exception does not help us any way to understand "why" the exception occurs, as the port seemingly is spelled correctly in elm.
Possible Solution
I think that if a warning (or even error) was added for unused "in ports" this would prevent bugs and googling, and possibly be quite cheap to implement as you already have usage tracking in the elm language server.
Context
I'm a beginner, trying to make ports do something for me one step at a time. I was stuck when I did not see why elm errored in the code in the screenshot above. I found this github issue for it, and figured it might help if this was implemented in the language server. elm/elm-lang.org#831
Feel free to close this if it is not relevant or too complicated.
Your Environment
- Version used: Elm-Tooling v1.5.3
- Editor used: VS Code
- Environment name and version (e.g. node.js 5.4): Elm 19.1
- Operating System and version: Windows 10
