Closed
Description
I want to re-export some class defined in a module scope from a nested namespace. First I tried new ES6 syntax, but got an error:
export class Foo {}
export namespace a {
export { Foo } // TS1194: Export declarations are not permitted in a namespace.
}
Ок, tried export import
:
export class Foo {}
export namespace a {
export import Foo = Foo; // TS2303: Circular definition of import alias 'Foo'.
}
So I have to define temporary import:
export class Foo {}
import FooTemp = Foo; // TS2503: Cannot find namespace 'Foo'.
Ok, let's declare module Foo
also:
export class Foo {}
export module Foo {}
import FooTemp = Foo;
export namespace a {
export import Foo = FooTemp;
}
And only now the compilation is successful. It's really complicated workaround. And it forces to define extra variable in generated JS. I would prefer the first or second code sample. Or maybe is there another way?