type 和 interface区别
1.类型别名可以用于其它类型 (联合类型、元组类型、基本类型(原始值)),interface不支持 type可以声明任何类型,interface不可以只能声明对象
2.interface 可以多次定义 并被视为合并所有声明成员 type 不支持
3.type 能使用 in 关键字生成映射类型,但 interface 不行
4.导出方式
// inerface 支持同时声明,默认导出 而type必须先声明后导出
export default interface Config {
name: string;
}
type Config = {name: string}
export default Config
5.interface可以被class继承和实现,也可以继承class type不可以

浙公网安备 33010602011771号