elm-lang / elm-package

Command line tool to share Elm libraries
BSD 3-Clause "New" or "Revised" License
214 stars 66 forks source link

Prevent publishing when types in public type signatures are unexposed #277

Open rtfeldman opened 7 years ago

rtfeldman commented 7 years ago

elm-css has a lot of PRs like this: https://github.com/rtfeldman/elm-css/pull/290

The basic problem is that I can expose a function like Int -> Foo -> String and forget to expose Foo. This means users of the package can partially apply this function and end up with a Foo -> String function that they cannot annotate, because Foo is not exposed.

It would be great if elm-package could give an error on publish if a public type signature incorporates a non-public type.

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 7 years ago

Nice suggestion, I'll see if I can add that in as well!

laszlopandy commented 7 years ago

For reference TypeScript has this check and it looks like this: Example.ts(12,24): error TS4060: Return type of exported function has or is using private name 'ExampleType'. Or: Example.ts(12,24): error TS4078: Parameter 'a' of exported function has or is using private name 'ExampleType'.

ianmackenzie commented 7 years ago

What exactly should it mean for a type to be exposed? Exposed directly from the module in which it is defined? Exposed via an alias in another module? (Does the alias have to have the same name as the original type?) I've added an example in #281.