title: Typescript library: Hide internal exports
body: <p>I am building a library in typescript that is being published via npm.</p>
  
  <p>In the index.ts, which is the starting point of the library, all the public classes and enums are exported.</p>
  
  <pre><code>import { MyClass } from './internal/my-class'
  import { MyEnum } from './internal/my-enum'
  export { MyClass, MyEnum }
  </code></pre>
  
  <p>This works well, but I noticed that users are able to import internal functions/classes etc. as well by using a direct path to the file.</p>
  
  <pre><code>// in a project that installed my library as an npm dependency
  import { InternalClass } from 'my-lib/dist/internal/internal-class'
  </code></pre>
  
  <p>Is there a way to prevent this?</p>
  
  <p>I need to "export" <code>InternalClass</code> because I'm importing and using it throughout my library, but I don't want to expose it publicly. I tried using namespaces, but couldn't really get it to work.</p>