Reputation: 2901
I am not sure if this is supported or not but I have a scenario where in my d.ts file I want to have the following declarations:
declare module final {
export class Test {
}
}
declare module root {
module final {
export class MainClass extends final.Test {
}
}
}
And the issue I having is that TypeScript "Property 'Test' does not exist on type 'typeof final'" for the extends final.Test
part.
So we are having a module name overlapping issue, is that resolvable without the need to make the names unique?
Upvotes: 0
Views: 336
Reputation: 121
You can use the type
keyword to declare an alias for final.Test
before declaring module.root
like this:
declare module final {
export class Test {
}
}
// define 'finalTest' as an alias
type finalTest = final.test;
declare module root {
module final {
export class MainClass extends finalTest {
}
}
}
Upvotes: 0
Reputation: 164129
There's no way to specify that you mean the other final
module.
What you can do is to name your modules with different names:
declare module final1 {
export class Test {}
}
declare module root {
module final2 {
export class MainClass extends final1.Test {}
}
}
Or you can place then under a shared parent:
declare module myModule {
export module final {
export class Test {}
}
}
declare module myModule {
declare module root {
module final {
export class MainClass extends myModule.final.Test {}
}
}
}
In the browser there's already a shared parent which is the window so you can just do:
export class MainClass extends window.final.Test {}
But I'm unsure how that's done in NativeScript
.
Upvotes: 1