title: Type sharing between frontend and backend without bundling the ORM
body: <p>In a fullstack typescript project i wish to share the interface/types that i use on the backend project in the frontend project to avoid code duplication and keep consistency.</p>
  
  <p>From search i found that this can be done by having a third "shared" project with these types and then using typescript's referenced projects to include it.</p>
  
  <p>So i would have a Frontend project, Backend project and a Shared project that would be referenced by the first two.</p>
  
  <p>Although my types extend the mongoose's Document type, witch would cause the need for mongoose to be bundled in the frontend project in order to use the same types in both the frontend and backend.</p>
  
  <p>What is the proper way to share these interfaces/types without bundling the extra backend packages to the frontend? (and keeping the _id property that comes from the Document extension as well while we are at it).</p>
  
  <p><strong>RoadBook.ts (IRoadBook is the interface/type to be shared and mongoose schema,model declaration)</strong></p>
  
  <pre><code>import mongoose, {Schema,Model,Document} from 'mongoose';
  
  export interface IRoadBook extends Document {
      Name  : string;
      Description : string;
  }
  
  const RoadBookSchema = new Schema({
      Name : {type : String, required : true, unique: true},
      Description : {type : String }
  });
  
  export default mongoose.model&lt;IRoadBook&gt;('RoadBook',RoadBookSchema);
  
  </code></pre>
  
  <p>Might be important to reference that the backend is a simple typescript/express/mongoose app and the frontend a react webapp.</p>
  
  <p>Thank you in advance.</p>