How can I export an interface from a namespace in typescript? Is this only possible with declaration files? Let me show you what I'm trying to achieve:
namespace Foo {
export interface Bar {}
export class Baz {}
}
export const { Baz } = Foo; // Working as expected
export const { Bar } = Foo; // Error: Type 'typeof Foo' does not have a property 'Bar'
Typescript 3.3.1
It's interesting to note that the official documentation includes this use case, which is why I was puzzled when it didn't work: https://www.typescriptlang.org/docs/handbook/namespaces.html
Update (thanks Titian):
My main goal was to export this type, and I managed to do so by following Titian's advice:
namespace Foo {
export interface Bar {}
export class Baz {}
}
export const type Bar = Foo.Bar // now exportable