Reputation: 77089
I'm using a JS module, with typings from Definitely Typed
, that has this structure:
declare namespace Foo {
interface Bar {}
}
declare module "abc" {
function f(): Foo.Bar
namespace f {
}
export = f;
}
How can I import the Bar
interface from "abc"
?
Upvotes: 1
Views: 287
Reputation: 12018
When something isn't explicitly exported, chances are, the author of the typings intends for you to not use the type.
...That being said, there technically is a way to get to it. TypeScript added a ReturnType
type in 2.9 along with conditional types, which allows you to get the return type of a function. Here, you'd use it like this:
import f from 'abc'
type Bar = ReturnType<typeof f>
Upvotes: 1