Reputation: 424
I want to create an interface in 'parent.a' namespace and I want to use that interface in 'parent' namespace.
Is there any way to do that, please help me on this.
I have found one solution to access classes from different namespaces access class from namespace but I need to work with interface not classes.
my example:
module Parent.AInterface {
export interface AInterface {
setParent(): void;
}
}
My other module
module Parent {
export class ParentClass implements AInterface {
}
}
while doing so.. I'm getting an error that says Cannot find name 'AInterface'
please help me on this.
Upvotes: 3
Views: 1325
Reputation: 73
Parent.ts
///<reference path="./Parent.AInterface.ts" />
module Parent {
export class ParentClass implements AInterface.AInterface {}
}
Upvotes: 0
Reputation: 7641
You should mention module name before interface name:
module Parent.AInterface {
export interface AInterface {
setParent(): void;
}
}
module Parent {
export class ParentClass implements AInterface.AInterface {
setParent() {
}
}
}
This works fine for me in the typescript playground.
Upvotes: 1