title: Access members of outer class in TypeScript
body: <p>Since TypeScript 1.6, we can easily create inner classes with <a href="https://stackoverflow.com/questions/32494174/can-you-create-nested-classes-in-typescript">class expressions</a>. In other OOP-centric languages like Java, inner classes can access members of the outer class, <a href="https://stackoverflow.com/questions/1801718/why-can-outer-java-classes-access-inner-class-private-members">even private ones</a>.</p>
  
  <p>This behavior is similar to concept of closures, where function could access variables from the scope in which it was defined.</p>
  
  <p>Why I can't achieve this in TypeScript? Does specification of classes in ECMAScript 2015 plays role here?</p>
  
  <p>Code that presents expected behavior:</p>
  
  <pre><code>class OuterClass {
      private outerField = 1337;
  
      public InnerClass = class { 
          public accessOuter() {
              return this.outerField; // outerField not defined
          }
      }
  }
  
  var outer = new OuterClass();
  var inner = new outer.InnerClass();
  var win = inner.accessOuter();
  </code></pre>