Reputation: 45464
I see something like
import foo = Bar.baz.lorem;
in some source code and it does not have a require()
call. Is this an old form if import? I don't see any examples in the docs.
Upvotes: 0
Views: 37
Reputation: 51609
This is TypeScript syntax for importing from namespaces, not modules. There was a time when namespaces were called "internal modules", and modules were "external modules". So import
from namespace can be used to introduce an alias to some entity defined in that namespace:
namespace Bar {
export namespace baz {
export const lorem = 42;
}
}
import foo = Bar.baz.lorem;
This import
is compiled into simple var
statement
var foo = Bar.baz.lorem;
and, except for its confusing name, has nothing to do with ES6 or CommonJS modules.
Upvotes: 2