mdgriffith/elm-codegen

Broken import statements when local module uses import aliases

Closed this issue · 1 comments

r-k-b commented

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: 3e7c055

image

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

r-k-b commented

This must have been resolved already, the import statements work fine in the current version.

Thanks for your work! 🙏