Reputation: 20229
Consider the following code (seen here):
declare module "foobar" {
export = typeof import("foobar")
}
What exactly does the second line do?
Doesn't it recursively refer to the same module?
Also, why is a type annotation accepted as an exported value?
Upvotes: 5
Views: 9518
Reputation: 21
The typeof
operator in TS resolves the type of a given variable. Imports return variables. So what this is doing is exporting the type of import('foo')
rather than the value of import('foo')
.
Upvotes: 2