title: How to properly use the same Class in Anglular and NodeJs server with Typescript
body: <p>I have the following file that I called models.ts</p>
  
  <pre><code>import {BusStage} from "./busStage";
  
  export class BusRoute {
      name: string;
      origin_direction_1: string;
      origin_direction_2: string;
      stops: number;
      id: string;
      meta: object;
      path: Direction;
      prev: string;
      next: string;
      arrival: Arrival;
  }
  export class Arrival {
      busstop_id: string;
      busstop_name: string;
      arrival_in: string;
      bus_left: string;
      all_arrivals: ArrivalSchedule[];
  }
  export class ArrivalSchedule{
      minutesLeft: string;
      arrivalTime: string;
      arrivalStatus:string;
  }
  export class Direction {
      direction1: BusStage[];
      direction2: BusStage[];
      direction3: BusStage[];
  }
  </code></pre>
  
  <p>My back end is NodeJs that supports Typescript and it serves my frontend which is Angular as static files. My server also exposes an API that allow both ends to communicate json request and responses. Now I want to use the same <code>models.ts</code> file in both frontend and backend without having to duplicate the file and manually synchronizing everytime I make a change.</p>
  
  <p>What is the correct way to do that? I was thinking of writing a script that watches any file change and copying it in both back end and front end folder everytime there is a change. However, I see it more as a workaround than a solution. Is what I am trying to achieve possible ?</p>
  
  <p>Here is my folder structure:</p>
  
  <pre><code>|models.ts
     |_frontend/
        |_src
        |_package.json
        |_tsconfig.json
        |_...
  
     |_backend/
        |_src
            |_server.ts
        |_dist/
        |_package.json
        |_tsconfig.json
        |_...
  </code></pre>