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

Prevent publishing when types in public type signatures are unexposed

Open rtfeldman opened this issue 7 years ago • 4 comments

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.

rtfeldman avatar Jul 11 '17 19:07 rtfeldman

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.

process-bot avatar Jul 11 '17 19:07 process-bot

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

evancz avatar Jul 11 '17 21:07 evancz

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'.

laszlopandy avatar Jul 12 '17 14:07 laszlopandy

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.

ianmackenzie avatar Aug 21 '17 16:08 ianmackenzie