You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be warned that an "in port" would be stripped if no subscription is implemented.
Current Behavior
port moduleMainexposing (..)
-- Define an inPort (but no implementation yet)port inPort: (String->msg) ->Submsgsubscriptions:Model->SubMsgsubscriptions _ =Sub.none -- inPort is never subscribed to
Currently 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.
Example from my context:
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
The text was updated successfully, but these errors were encountered:
Strepto
changed the title
Warn for "in" port without subscription
Suggestion: Warn for "in" port without subscription
Nov 8, 2020
Expected Behavior
I would like to be warned that an "in
port
" would be stripped if no subscription is implemented.Current Behavior
Currently 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.Example from my context:
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
The text was updated successfully, but these errors were encountered: