Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access class in same module but in different file

Tags:

typescript

Suppose I have the following code in the following two files:

ClassA.ts

module App {
    class ClassA{
    }
}

ClassB.ts

module App {
    export class ClassB{
        constructor(public ClassA) {}
    }
}

Is there any way to make ClassA accessible to classB without adding an export to ClassA? In other words, I want ClassA to only be accessible within the App module, but I also want to keep my classes in separate files.

Even when the compilation is output to a single file ClassA cannot access ClassB without the export.

like image 634
Dave Graves Avatar asked Apr 15 '13 23:04

Dave Graves


1 Answers

There isn't a way to do this. Non-exported variables in modules are generated as locals in the module closure, so they're not visible at all outside the module block itself.

like image 124
Ryan Cavanaugh Avatar answered Oct 17 '22 06:10

Ryan Cavanaugh