P Varga
P Varga

Reputation: 20229

What does export=typeof import() mean?

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

Answers (1)

Edward Drapkin
Edward Drapkin

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

Related Questions