title: How to avoid "Module not found: Error: Can't resolve 'tslib'"-error when referencing an external typescript file?
body: <h1>The question</h1>
  
  <p>I have a client/server application, where the client is an angular-app. The server does provide a couple of typescript-definitions for the API it provides. These definitions are loaded from a project-external folder. So far this worked fine, however now I am upgrading from Angular 7 to Angular 8 (and with that also upgrading Typescript from Version 3.1 to 3.5) and when trying to use a non-static enum from the definitions, this now produces this error:</p>
  
  <blockquote>
    <p>Module not found: Error: Can't resolve 'tslib' in '/path/to/server/definitions'</p>
  </blockquote>
  
  <p>When the <code>api.ts</code>-file is located within the client-dir, then everything works just fine.</p>
  
  <p><strong>Why is this happening and what I can I do about it?</strong></p>
  
  <h1>Creating a minimal reproducible example</h1>
  
  <p>Here is a quick script to create a minimal example to reproduce:</p>
  
  <pre class="lang-sh prettyprint-override"><code>mkdir project
  cd project
  ng new client --minimal=true --skipGit=true --routing=false --style=css
  mkdir server
  echo 'export enum ApiSample { X = "X" }' &gt; server/api.ts
  sed -i 's/"compilerOptions": {/"compilerOptions": {"paths":{"api":["..\/server\/api"]},/' client/tsconfig.json
  sed -i -e "1iimport { ApiSample } from 'api';" -e "s/title = 'client';/title = 'client' + ApiSample.X;/" client/src/app/app.component.ts
  cd client
  npm start
  </code></pre>
  
  <p>Or, alternatively, to create an example manually:</p>
  
  <ol>
  <li>Create a new angular project</li>
  <li>Create somewhere in the filesystem a file "api.ts" with the content <code>export enum ApiSample { X = "X" }</code></li>
  <li>In the "tsconfig.json" Add <code>{"paths":{"api":["/path/to/server/api"]}</code> to the <code>compilerOptions</code></li>
  <li>Access the <code>ApiSample.X</code> from any file of the angular project</li>
  <li>Run <code>npm start</code></li>
  </ol>
  
  <h1>Findings so far</h1>
  
  <ul>
  <li>The migrator added <code>"importHelpers": true</code> in tsconfig.json. That is why it worked before and is not working anymore now. Specifying <code>"importHelpers": false</code> in tsconfig.json fixes the issue, but of course this option is there for a reason, so that is no final solution</li>
  <li>Explicitly specifying <code>"tslib": ["node_modules/tslib"]</code> fixes the problem. This may be a final solution although it would be interesting to know what is exactly happening and where this is documented.</li>
  </ul>