Skip to content
Frontend Masters
搜索文档
Main Navigation
指南
核心概念
语言基础
框架与库
导读
前端框架
Vue
React
后端框架
Node.js
Express
Koa
NestJS
工程化
Appearance
Menu
Return to top
本页目录
TypeScript 中 interface 和 type 有什么区别?
interface 和 type 都可以用来定义对象类型,但 interface 创建的对象类型只能是类创建的对象,而 type 创建的对象类型可以是类创建的对象,也可以是函数创建的对象。
interface 可以继承,type 不能继承。
interface 可以重复定义,type 不能重复定义。
interface 可以定义属性,type 不能定义属性。
interface 可以定义方法,type 不能定义方法。