sparksp / elm-review-imports

elm-review rule to enforce consistent import aliases
https://package.elm-lang.org/packages/sparksp/elm-review-imports/latest/
MIT License
14 stars 4 forks source link

Shadowing when aliasing a type with the same name #127

Open miniBill opened 1 year ago

miniBill commented 1 year ago

Proposed fix:

-- (fix) NoModuleOnExposedNames: Module used on exposed type `Dict`.

type alias Dict k v =
    Internal.Dict k v
    ^^^^^^^^^^^^^

It is not necessary to use the module here as `Dict` was exposed on import.

You should remove the module from this call, or remove the name from the import
.. exposing list.

Except it is in fact necessary to do that (and exposing the type is done to import the constructors/variants, so can't be avoided)

sparksp commented 1 year ago

Thank-you for the SSCCE. Some more context for this, so that it's not lost. The original bug report on Slack...

I'm running into a bit of a problem with elm-review. I have something like

module MyModule exposing (Thing)

import MyModule.Internal exposing (Thing(..))

type alias Thing = MyModule.Internal.Thing

... functions that use Thing(..) ...

Now elm-review complains about the type alias and wants to change it to type alias Thing = Thing which does not compile.

I can easily work around the problem locally, of course, but I am wondering if elm-review could be made to handle this?

sparksp commented 1 year ago

I have taken a look in to this today and found a few things I want to note for myself (or another fixer)...