Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  40] [ 6]  / answers: 1 / hits: 114485  / 9 Years ago, thu, september 10, 2015, 12:00:00

Is there a way to nest classes in TypeScript. E.g. I'd like to use them like:



var foo = new Foo();
var bar = new Foo.Bar();

More From » typescript

 Answers
8

In modern TypeScript we have class expressions which you can use to create a nested class. For example you can do the following :


class Foo {
static Bar = class {

}
}

// works!
var foo = new Foo();
var bar = new Foo.Bar();

[#65118] Tuesday, September 8, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
raymondd questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
Thu, Jul 25, 19, 00:00, 5 Years ago
;