title: TypeScript properties returning a promise - Get/Set accessors must have the same type
body: <p>Why does TypeScript enforce Get/Set accessors to have the same type?
  Let's say I want to have a property which returns a promise.</p>
  
  <pre><code>module App {
      export interface MyInterface {
          foo: ng.IPromise&lt;IStuff&gt;;
      }
  
      export interface IStuff {
          bar: string;
          baz: number;
      }
  
      class MyClass implements MyInterface {
          private _fooDeferred: ng.IDeferred&lt;IStuff&gt;;
  
          constructor(private $q: ng.IQService) {
              this._fooDeferred = this.$q.defer();
          }
  
          get foo(): ng.IPromise&lt;IStuff&gt; {
              return this._fooDeferred.promise;
          }
  
          set foo(value: IStuff) {
              this._fooDeferred.resolve(value);
          }
      }
  }
  </code></pre>
  
  <p><strong>'Get' and 'Set' accessor must have the same type</strong> will be the error message coming from TypeScript.</p>
  
  <p>The fix would be to type the accessors to <strong>any</strong>, but then we are losing the advantages of static typing, and might as well just write JS.</p>
  
  <pre><code>        get foo(): any {
              return this._fooDeferred.promise;
          }
  
          set foo(value: any) {
              this._fooDeferred.resolve(value);
          }
  </code></pre>