Multiple entrypoints in typescript external modules not resolved
<p>I am trying to build an external module, <code>@example/lib</code> for TypeScript with multiple entry points.  I would like to consume it something like this:</p>

<pre><code>import * as lib from '@example/lib';
import * as foobar from '@example/lib/foobar';
</code></pre>

<p>I can build an npm module which works correctly by setting <code>"target": "es5"</code> and <code>"declaration": true</code> in my tsconfig, and pointing my <code>"main"</code> and <code>"typings"</code> properties in the <code>package.json</code> to a single source location.  If I do this, I can always import <code>@example/lib</code> without issue.</p>

<p>The problem arises when I attempt to import <code>@example/lib/foobar</code>.  TypeScript complains that it "Cannot find module <code>@example/lib/foobar</code>".  The compiled output, however can import this submodule perfectly fine (after being processed by webpack).</p>

<p>Inside my <code>@example/lib</code> project I have the source files:</p>

<pre><code>index.js
index.d.ts
foobar.js
foobar.d.ts
</code></pre>

<p>And in my package.json I have:</p>

<pre><code>{
    ...
    "typings": "index.d.ts"
    "main": "index.js"
    ...
}
</code></pre>

<p>What do I need to do to keep TypeScript happy (and type checking!) in this case?</p>