学习中心 /编程 /TypeScript /进阶提高 /类型别名与接口
🟦 TypeScript 进阶提高 💾 下载配套软件

类型别名与接口

type 和 interface 的取舍。

📅 2026-11-23 👁 19 次阅读

本节要解决的问题

type 和 interface 的取舍。

核心要点

  • interface 可声明合并,适合对象结构
  • type 能表达联合、交叉和映射类型
  • 两者多数场景可以互换
type ID = string | number;\ninterface Point { x: number; y: number; }
描述对象用 interface,复杂组合用 type。