uhyoooooo
uhyoooooo

Reputation: 61

TypeScript: Splitting module into multiple files

I want to split class definitions in a same module into multiple files. So I did like this and it worked.

a.ts:
module MyModule{
    class ClassA{
    }
}

b.ts:
module My Module{
    class ClassB{
    }
}

Then I tried to use ClassA in ClassB and did that:

b.ts:
///<reference path="a.ts"/>
module MyModule{
    class ClassB{
        private a:ClassA;
    }
}

But it didn't work; "ClassA" needed to be "MyModule.ClassA" in b.ts though they're in the same module.

I prefer a simpler way like above. Do you have any ideas?

Upvotes: 6

Views: 2421

Answers (1)

Fenton
Fenton

Reputation: 250842

You can solve your problem by making the class public:

module MyModule{
    export class ClassA{
    }
}

I'm not sure why you need to do this as really they are part of the same module - but this seems to be the case.

Upvotes: 2

Related Questions