TypeScript · Classes and modules

Namespace import

Imports all named exports as a single object.

Syntax
import * as api from "./api"

Example

Example
// import * as api from "./api.js";
// api.load();
console.log("Namespaces keep a module’s exports under one name.");

More in this group

abstract class Access modifiers Class Declaration file implements readonly field Type-only import

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course