To use namespaces with import in TypeScript, we can create ES6 modules and import them.
For instance, we write
UtilBase.ts
import * as path from "path";
export default class UtilBase {
protected fixPath(value: string): string {
return value.replace("/", path.sep);
}
}
to export the UtilBase
class as a default export.
Then we can import the module as a default import with
import UtilBase from "./UtilBase";
export default class UtilOne extends UtilBase {
//...
}