title: Import syntax with TypeScript project references
body: <p>What is the proper way to import modules from another sub-project in TypeScript?</p>
  
  <p>I have this project structure:</p>
  
  <pre><code>myproject/
    tsconfig.json
    tsconfig-base.json
    src/
      tsconfig.json
      core/
        A.ts
        B.ts
      extra/
        C.ts
        D.ts
    test/
      tsconfig.json
      test.ts
    built/
      core/...
      extra/...
      test/...
  </code></pre>
  
  <p>tsconfig-base.json:</p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "ES2018",
      "module": "commonjs",
      "declaration": true,
      "outDir": "built",
      "composite": true,
      "strict": true,
      "esModuleInterop": true,
      "forceConsistentCasingInFileNames": true
    }
  }
  </code></pre>
  
  <p>tsconfig.json:</p>
  
  <pre><code>{
      "files": [],
      "includes": [],
      "references": [
          { "path" : "./src" }, 
          { "path" : "./test" }
      ]
  }
  </code></pre>
  
  <p>src/tsconfig.json:</p>
  
  <pre><code>{
      "include": ["**/*"],
      "extends": "../tsconfig-base.json",
      "compilerOptions": {
          "rootDir": "."
      }
  }
  </code></pre>
  
  <p>test/tsconfig.json:</p>
  
  <pre><code>{
      "extends" : "../tsconfig-base.json",
      "include" : ["*"],
      "references": [
          { "path": "../src" }
      ],
      "compilerOptions" : {
          "outDir": "../built/test",
          "rootDir": "."
      }
  }
  </code></pre>
  
  <p>In <code>test/test.ts</code>, I do:</p>
  
  <pre><code>import { Thing } from "../core/A"
  </code></pre>
  
  <p>Because <a href="https://github.com/microsoft/TypeScript/issues/27572" rel="nofollow noreferrer">this thread</a> suggests that modules should be imported "from wherever they end up" when using <code>outDir</code>, I would expect the above to work (because <code>built/core/A.js</code> is relative to <code>built/test/test.js</code> via the specified path). Similarly, the <a href="https://www.typescriptlang.org/docs/handbook/project-references.html" rel="nofollow noreferrer">TypeScript docs on project references</a> show an example with similar structure with an <code>import</code> omitting "src" as above.</p>
  
  <p>Instead, I get:</p>
  
  <pre><code>test/test.ts:1:28 - error TS2307: Cannot find module '../core/A'.
  
  1 import { Thing } from "../core/A"
  </code></pre>
  
  <p>Why is this? How does TypeScript search for imports when using project references? (Note that in this case, it would be untidy to be forced to include "<code>src/</code>" in all the import paths).</p>
  
  <p>What is the proper way to accommodate the project structure above?</p>
  
  <p>Thanks!</p>