6

Closed

Nested Class

description

Any plans to suport nested class? Ex:






class Store {
class Error{

}
}
Closed Mar 12, 2013 at 4:56 PM by jonturner
This is a duplicate. Tracking against #132

comments

fletchsod wrote Dec 26, 2012 at 7:21 PM

I'm afraid that wouldn't work, not the way of how class(es) works... A more correct way of doing this would be doing this within the same namespace.

class Store {
}
class Error {
}

But that wouldn't be called nest class.

fletchsod wrote Dec 31, 2012 at 5:40 PM

P.S. - Let's see what other folks have to say (feedback) on this.

jonturner wrote Mar 12, 2013 at 4:49 PM

We're currently working on a spec proposal for a more flexible feature that would allow you to "mix" abstractions together. Where as currently you can mix two interfaces of the same now to create a new interface, we're looking into allowing an example like the following:
class Store { }
module Store {
  class Error { }
}
The resulting 'Store' could be instantiated like a class, but could also be used in a namespacing position, allowing you to say "var x: Store.Error"

jonturner wrote Mar 12, 2013 at 4:56 PM

A couple more things.

This issue is closely related to http://typescript.codeplex.com/workitem/132, which is more general. I'm going to close this issue so we can track against that one.

Also, my previous example should export the class to get the intended effect:
class Store { }
module Store {
  export class Error { }
}