title: 'rootDir' is expected to contain all source files
body: <p>I have an Angular CLI workspace containing two library projects, <code>foo</code> and <code>bar</code>. When I build the second of the two libraries, <code>foo</code>, the build fails with the following error:</p>
  
  <blockquote>
    <p>error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under
    'rootDir' '/code/projects/foo/src'. 'rootDir' is expected tocontain
    all source files.</p>
  
  <pre><code>Error: error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under 'rootDir' '/code/projects/foo/src'. 'rootDir' is expected to contain all source files.
  
      at Object.&lt;anonymous&gt; (/code/node_modules/ng-packagr/lib/ngc/compile-source-files.js:53:68)
      at Generator.next (&lt;anonymous&gt;)
      at /code/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
      at new Promise (&lt;anonymous&gt;)
      at __awaiter (/code/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
      at Object.compileSourceFiles (/code/node_modules/ng-packagr/lib/ngc/compile-source-files.js:19:12)
      at Object.&lt;anonymous&gt; (/code/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:26:32)
      at Generator.next (&lt;anonymous&gt;)
      at /code/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
      at new Promise (&lt;anonymous&gt;)
  </code></pre>
  </blockquote>
  
  <p>I have reproduced the error in a sandbox repo on GitHub <a href="https://github.com/samherrmann/angular-sandbox/commit/0c676a44c7dcc17b684323660cda24f7bc699ec9" rel="noreferrer">here</a>. I have simplified the code to as much as I can while still experiencing the error. You can reproduce the error by executing <code>npm run build</code> on the <a href="https://github.com/samherrmann/angular-sandbox/compare/rootDir-expect-all-source-files-error" rel="noreferrer">rootDir-expect-all-source-files-error</a> branch. What is the cause of the error? May this be a bug with <code>ng-packagr</code> or <code>ngc</code> or <code>tsc</code>? Or is it simply a configuration issue?</p>
  
  <h1>Observations</h1>
  
  <p>Below are code changes with which I can make the build pass, but I would like to know what is causing the error with the code as is.</p>
  
  <h2>bar.component.ts</h2>
  
  <h3>Build fails</h3>
  
  <pre><code>export class BarComponent {
  
    list = this.barService.list();
  
    constructor(private barService: BarService) {}
  }
  </code></pre>
  
  <h3>Build passes</h3>
  
  <p>Initialize list property in constructor instead of inline</p>
  
  <pre><code>export class BarComponent {
  
    list;
  
    constructor(private barService: BarService) {
      this.list = this.barService.list();
    }
  }
  </code></pre>
  
  <h2>bar.service.ts</h2>
  
  <h3>Build fails</h3>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { List, Item } from './types';
  
  @Injectable({
    providedIn: 'root'
  })
  export class BarService {
  
    private _list: List = [];
  
    constructor() { }
  
    add(item: Item): void {
      this._list.push(item);
    }
  
    list(): List {
      return this._list;
    }
  }
  </code></pre>
  
  <h3>Build passes</h3>
  
  <p>Remove the data types</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  @Injectable({
    providedIn: 'root'
  })
  export class BarService {
  
    private _list: any[] = [];
  
    constructor() { }
  
    add(item: any): void {
      this._list.push(item);
    }
  
    list(): any {
      return this._list;
    }
  }
  </code></pre>