elm-package
elm-package copied to clipboard
Prevent publishing when types in public type signatures are unexposed
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.
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.
Nice suggestion, I'll see if I can add that in as well!
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'.
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.