命名空间
防止命名冲突问题
使用namespace
关键字定义, 在外部使用需要export
导出
定义
ts
namespace aa {
export class Person {
constructor(
public name: string,
public age: number
){ }
}
}
namespace bb {
export class Person {
constructor(
public gender: string,
public email: string
) {}
}
}
使用
ts
let p1 = new aa.Person('张三', 18)
let p2 = new bb.Person('男', '123@qq.com')