title: How can I return a success and an error promise with and without data?
body: <p>I would like to return a promise and an object called <code>output</code> either before or after the $http call. Can someone advise me how I can do this with the AngularJS framework and very important with <strong>Typescript</strong> so I can be sure it is working correctly? </p>
  
  <pre><code> topicNewSubmit = (): ng.IPromise&lt;any&gt; =&gt; {
      var self = this;
      var myData1 = { abc: 123 }
  
      if (self.abc = 22) {
          // How can I return an OKAY promise from here?
      }
      if (self.abc = 33) {
          // How can I return an OKAY promise with myData1 from here?
      }
      if (self.abc = 88) {
          // How can I return a FAIL promise from here?
      }
  
      return self.$http({ url: self.url, method: "GET" })
          .then(
              (response: ng.IHttpPromiseCallbackArg&lt;any&gt;): any =&gt; {            
              var myData2 = { abc: 245 }
              // How can I return a promise and myData2. 
              // return(myData2) gives an error with Typescript
  
              // How can I return a promise and no data
              // return gives an error with Typescript 
          },
          (error: ng.IHttpPromiseCallbackArg&lt;any&gt;): ng.IPromise&lt;any&gt; =&gt; {
              var myData3 = { abc: 345 }
              // Is this the correct way to return an unhandled reject with myData3
              return self.$q.reject(myData);
          });
    }
  </code></pre>