title: TypeScript Class Inheritance: 'super' Can Only Be Referenced in Members of Derived Classes or Object Literal Expressions
body: <p>We're using TypeScript classes with inheritance and have run into an apparent scoping issue. TypeScript/JavaScript is not allowing us to call 'super' from within a promise structure (or even from an enclosed function). We're receiving this error:</p>
  
  <p><strong>TypeScript: 'super' Can Only Be Referenced in Members of Derived Classes or Object Literal Expressions</strong></p>
  
  <p>Is there a way around this? Here's the code:</p>
  
  <pre><code>export class VendorBill extends Transaction {
      constructor() {
          super();
      }
  
      save() {
  
          let deferred = $.Deferred();
  
          $.ajax({
              type: "GET",
              url: '/myrestapi',
              success: function (data) {    
                  deferred.resolve();    
              },
              error: function (jqXHR: any, textStatus, errorThrown) {
                  deferred.reject()
              }
          })
  
          $.when(deferred).always(function () {
              super.save();  &lt;----------- THIS IS CAUSING THE ERROR
          })    
      }
  }
  </code></pre>