title: Importing TypeScript types outside of src in React
body: <p>I have been working on a <code>React + Express</code> project lately which has a project file structure like this:</p>
  <pre><code>Repo
    |--ExpressApp
        |--src/..
    |--Common
        |--types.ts
    |--ReactApp
        |--src/..
  </code></pre>
  <p>So the express app lives within the <code>ExpressApp</code> folder, the react app lives within the <code>ReactApp</code> folder, and inside of <code>Common</code> are a set of <code>Typescript</code> types that are shared between the express and react applications.</p>
  <p>The react application is a <code>create-react-app</code> project, and I have read issues associated with importing files that reside outside of the react apps src directory.  However, in the React application, I seem to be able to import the types that are specified from the <code>Common/types.ts</code> into the React application without any problem.</p>
  <pre class="lang-js prettyprint-override"><code>/** Common/types.ts */
  
  // This imports ok to React app even though its outside of the src directory
  export type Person {
   id: string,
   name: string,
   role: string
  };
  
  // This does not import into React app, as it is outside of the source directory
  export const smapleFunction = () =&gt; {
    ...
  }
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>/** ReactpApp/src/app.ts */
  
  // This is accepted by React
  import { Person } from '../../common/types';
  
  // This is not accepted by React
  import { sampleFunction } from '../../common/types';
  
  </code></pre>
  <p>If I was to export a function from the Common/types.ts file and use it within the React application, then react throws the expected error that files must reside within the src directory - however, no issue is found when importing types, interfaces etc.</p>
  <p>Could somebody please explain why this seems to be work for typescript types residing outside of src, but not for functions or other modules?  I'm assuming it has something to do with how Typescript is handled within a CRA project, but I don't quite understand the process?</p>