title: Realm Object relationships using typescript
body: <p>I am implementing a realm model. (similar as discussed here: <a href="https://github.com/realm/realm-js/issues/1795" rel="nofollow noreferrer">https://github.com/realm/realm-js/issues/1795</a>).</p>
  
  <pre><code>class Artist {
      // [index: string]: any;
      public static schema: Realm.ObjectSchema = {
              name: 'Artist',
              primaryKey: 'identifier',
              properties: {
                  name:  'string',
                  identifier: 'string',
                  albums: 'Album[]',
              }
      };
  
      public name: string;
      public identifier: string;
  
      constructor(name: string, identifier: string) {
          this.name = name;
          this.identifier = identifier;
      }
  
      public hasAlbum(album: Album): boolean {
          const filteredAlbums: Realm.Results&lt;Album&gt; = this.albums.filtered("identifier == $0", album.identifier);
          return filteredAlbums.length &gt; 0;
      }
  };
  </code></pre>
  
  <p>This works fine in typescript as I just need to declare the variables and their type.
  The issue starts with declaring object relationships such as:</p>
  
  <pre><code>properties: {
      albums: 'Album[]'
  }
  </code></pre>
  
  <p>In the Realm schema. This tells Realm that we want a list of Albums (which also is a Model).
  Now I need to tell typescript that my class has a property called Albums.</p>
  
  <ol>
  <li>Option: As an array</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>public albums: Album[];
  </code></pre>
  
  <p>The downside to this is that I can't use Realm.Results' methods such as filtered or others. Also I'd need to initialise the array with a value technically overwriting what comes back from the database.</p>
  
  <ol start="2">
  <li>Option: As Realm.Results</li>
  </ol>
  
  <pre class="lang-js prettyprint-override"><code>public albums: Realm.Results&lt;Album&gt;;
  </code></pre>
  
  <p>The issue here is that I must give it a value either directly or in the constructor. I can't give it a value really (nor does an empty results construct exist).</p>
  
  <ol start="3">
  <li>Option: Adding an index signature (removing the property declaration)</li>
  </ol>
  
  <p>I could add: [index: string]: any; to my class which let's me do all sorts of operations.
  And doing this raises the question why I should be using typescript if it does not warn me about type safety because I turned it off.</p>
  
  <p>Does anybody know an idea on how I can declare properties in typescript "without initialising" them and using them inside my class?</p>
  
  <p>Thanks! </p>