Angular 2 define data models for multiple modules
<p>I'm currently starting a new project with Angular 2.0 (release Version) and I want to define some global data models/schemas. As I understand it, Angular 2 has no default way of handling pure data classes like this:</p>

<pre><code>export class TestModel {
  id: number;
  name: string;
  randomAttribute: number;
  author: string;
}
</code></pre>

<p>So my first question regarding best practices is: <strong>Should I define such classes when working with Angular 2?</strong> </p>

<p>For the design and concept of my whole application I think they are necessary but I'm not sure if I'm applying the wrong way of thinking here.</p>

<p>This data classes are sometimes needed in multiple modules (<a href="https://angular.io/docs/ts/latest/guide/ngmodule.html" rel="noreferrer">ngModule</a>) so my second question is <strong>Where do I place them in my app?</strong> Currently I have the following structure:</p>

<pre><code>/app
   /shared
      shared.module.ts
      test.model.ts
   /module1
      module1.module.ts
      foo.component.ts
      [...]
   /module2
      module2.module.ts
      bar.component.ts
      [...]
   app.module.ts
   [...]
</code></pre>

<p>My first thought was to include the <code>instruction.model.ts</code> in the <code>shared.module</code> and export it in every module that imports <code>shared.module</code>. That doesn't seem to work because the model is not a directive, pipe or module. <strong>Is there a way to export it anyway?</strong></p>

<p>The simpler solution would be to just directly import the <code>test.model.ts</code> file and every other shared model in every module that needs it. But this seems clunky and not convenient for multiple models. </p>

<p>The third possible solution I thought of was to put all shared data models in a separate folder, bundle their export in a single file like the one below and import this file in every module that needs it. </p>