diff --git a/src/Elm.elm b/src/Elm.elm index 4b7389f..0240686 100644 --- a/src/Elm.elm +++ b/src/Elm.elm @@ -2183,7 +2183,12 @@ portIncoming nameStr arg = , typeAnnotation = Compiler.nodify (Annotation.FunctionTypeAnnotation - (Compiler.nodify (Compiler.getInnerAnnotation index arg)) + (Compiler.nodify + (Annotation.FunctionTypeAnnotation + (Compiler.nodify (Compiler.getInnerAnnotation index arg)) + (Compiler.nodify (Annotation.GenericType "msg")) + ) + ) (Compiler.nodify sub) ) } @@ -2459,4 +2464,3 @@ typeConstructorIsExposed name (Node _ node) = Expose.TypeExpose myType -> name == myType.name - diff --git a/tests/Declare.elm b/tests/Declare.elm index f91331a..bb4f285 100644 --- a/tests/Declare.elm +++ b/tests/Declare.elm @@ -22,6 +22,7 @@ suite = , customTypeTest , customTypeWithTest , newStyleTest + , ports ] @@ -396,3 +397,19 @@ makeAndCaseGenerationFullyDynamic = """ ] () + + +ports : Test +ports = + describe "ports" + [ test "incoming" <| + \_ -> + Elm.portIncoming "receive" Type.int + |> Elm.Expect.declarationAs + "port receive : (Int -> msg) -> Sub msg" + , test "outgoing" <| + \_ -> + Elm.portOutgoing "send" Type.int + |> Elm.Expect.declarationAs + "port send : Int -> Cmd msg" + ]