elm-codegen icon indicating copy to clipboard operation
elm-codegen copied to clipboard

Broken import statements when local module uses import aliases

Open r-k-b opened this issue 2 years ago • 0 comments

For example, this file:

module BadModuleNamedWith exposing (dummyDecoder)

import Json.Decode as JD


dummyDecoder : JD.Decoder String
dummyDecoder =
    JD.succeed ""

would produce Gen code containing:

{-| dummyDecoder: JD.Decoder String -}
dummyDecoder : Elm.Expression
dummyDecoder =
    Elm.value
        { importFrom = [ "BadModuleNamedWith" ]
        , name = "dummyDecoder"
        , annotation = Just (Type.namedWith [ "JD" ] "Decoder" [ Type.string ])
        }

which would then produce generated code that contains import JD instead of import Json.Decode.

I've added a test case to demonstrate: 3e7c05574c315658e77ddae4948c96b3386b4817

image

Thanks for creating elm-codegen, it's fantastic! :pray:

r-k-b avatar Oct 08 '23 00:10 r-k-b