Module name confusion

Topics: General
Jan 21, 2014 at 4:45 PM
Hi all,

I'm a newbie and I can't understand what's wrong with this code.

File: mymodule.d.ts
declare module my.example {
    export class Test {
        public do_something(): void;
    }
} 

declare module com.my.example {
    export class SubTest extends my.example.Test {
        public do_somethig_different(): void;
    }
}
When I compile the solution I get this error from the compiler:
mymodule.d.ts(8,45): error TS2094: Build: The property 'Test' does not exist on value of type 'example'.
I'm using typescript 0.9.5 with visual studio 2012.

Thanks,
Andrea
Coordinator
Jan 21, 2014 at 4:53 PM
In the second module, my.example refers to com.my.example. The submodule my in com shadows the global my. You'll need to name them differently or use an import statement to get a reference to the shadowed module.
Jan 21, 2014 at 5:06 PM
I used the import statement and it worked:
declare module my.example {
    export class Test {
        public do_something(): void;
    }
} 

import t = my.example;

declare module com.my.example {
    export class SubTest extends t.Test {
        public do_somethig_different(): void;
    }
}
Thanks,
Andrea