<p dir="auto">When building a large library many classes need to define fields and methods that are meant only for use by other classes within the library, not the client. There is no simple way to express this in TypeScript. One can duplicate the entire public API in a set of mirror interfaces classes, but that creates a lot of duplicated code &amp; doc maintenance, and sometime you really want to expose class names to the client. There appears to be a common convention of using the <a class="user-mention notranslate" data-hovercard-type="organization" data-hovercard-url="/orgs/internal/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/internal">@internal</a> JSDoc tag in this situation but it is not enforced by the compiler nor recognized by JSDoc.</p>
<p dir="auto">The solution in Java is package-private access. The analogous mechanism in TS would be namespace-private access.</p>
<p dir="auto">Currently to protect integrity of data one can only use classes with private or protected fields. Classes are harder to work with compared to object literals. Being able to specify that certain fields are invisible to outside modules would be a valuable addition to support programming in functional style in TypeScript.</p>
<p dir="auto">So what I am suggesting is to be able to specify whether a field of an interface is exported from a module or not. This also means that the instance of such interface can only be created within the module it is declared.</p>
<p dir="auto">The similar features can be found in:</p>
<ul dir="auto">
<li>F# called <code class="notranslate">signature files</code>: <a href="http://msdn.microsoft.com/en-us/library/dd233196.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd233196.aspx</a></li>
<li>Haskell called <code class="notranslate">export lists</code>: <a href="http://www.haskell.org/onlinereport/modules.html" rel="nofollow">http://www.haskell.org/onlinereport/modules.html</a></li>
</ul>