diff --git a/src/NoUnused/Exports.elm b/src/NoUnused/Exports.elm index c1eec186..f088b074 100644 --- a/src/NoUnused/Exports.elm +++ b/src/NoUnused/Exports.elm @@ -572,8 +572,8 @@ typesUsedInDeclaration moduleContext declaration = Declaration.AliasDeclaration alias_ -> ( collectTypesFromTypeAnnotation moduleContext alias_.typeAnnotation, False ) - Declaration.PortDeclaration _ -> - ( [], False ) + Declaration.PortDeclaration signature -> + ( collectTypesFromTypeAnnotation moduleContext signature.typeAnnotation, False ) Declaration.InfixDeclaration _ -> ( [], False ) diff --git a/tests/NoUnused/ExportsTest.elm b/tests/NoUnused/ExportsTest.elm index 3ff99399..d33e496e 100644 --- a/tests/NoUnused/ExportsTest.elm +++ b/tests/NoUnused/ExportsTest.elm @@ -514,6 +514,28 @@ main = type1 """, """module B exposing (Type1) type Type1 = Type1 +""" ] + |> Review.Test.runOnModulesWithProjectData application rule + |> Review.Test.expectNoErrors + , test "should not report an exposed type if it is used in a port (input)" <| + \() -> + [ """module Main exposing (main) +import B +main = somePort +port somePort : (B.Type1 -> msg) -> Sub msg +""", """module B exposing (Type1) +type alias Type1 = { user : String } +""" ] + |> Review.Test.runOnModulesWithProjectData application rule + |> Review.Test.expectNoErrors + , test "should not report an exposed type if it is used in a port (output)" <| + \() -> + [ """module Main exposing (main) +import B +main = somePort +port somePort : B.Type1 -> Cmd msg +""", """module B exposing (Type1) +type alias Type1 = { user : String } """ ] |> Review.Test.runOnModulesWithProjectData application rule |> Review.Test.expectNoErrors