- 接口合并重载
//声明相同接口时会合并,此时相当于声明了两个createFnc属性(重载)
interface face {
createFnc(name: string): (number: number) => number
}
interface face {
createFnc(namx: number): (string: string) => number
}
//实现重载可以用联合属性
createFnc(name: string | number): (number: number | string) => number {
return (num: number) => num + 20;
}
- 命名空间合并
export namespace aaa {
export const ccc = "Aa";
const dd = "dd";
}
export namespace aaa {
// 此处访问不到dd因为不共享相同命名空间中未导出的声明
export let saydd = () => {
console.log(dd);
}
}