TypeScript has 'interface' and 'type', so when to use which?

interface hasName {
firstName: string;
lastName: string;
} interface hasAddress {
address: string
} type Player = (hasName & hasAddress) | null; let player: Player = {firstName: 'Joe', lastName: 'Jonse', address: 'USA'};

It is recommended that to use 'interface' to define the props that obj should have.

'type' is recommended to use when combine multi interfaces to descide a single object like what we show in example.

最新文章

  1. 图片的赖加载(lazyLoad)
  2. com.opensymphony.xwork2.ognl.OgnlValueStack] - target is null for setProperty(null, "emailTypeNo", [Ljava.lang.String;@6f205e]
  3. 动易CMS之标签管理
  4. [NOIP2015] 提高组 洛谷P2668 斗地主
  5. Oracle 11g r2 x64 中文乱码解决方案
  6. DNA Sorting 分类: POJ 2015-06-23 20:24 9人阅读 评论(0) 收藏
  7. 关于配置php源代码管理环境的几点注意
  8. hdu 5442 Favorite Donut 后缀数组
  9. MySQL慢查询(一) - 开启慢查询
  10. 私人定制javascript中数组小知识点(Only For Me)
  11. Ffmpeg简介
  12. easynetq发布订阅demo实现注意事项
  13. Python爬虫入门教程 4-100 美空网未登录图片爬取
  14. Python第一天:你必须要知道的Python擅长领域以及各种重点学习框架(包含Python在世界上的应用)
  15. 一种使用 sprintf 导致死机的情况
  16. gitlab之一: gitlab安装配置使用
  17. go语言中goroute使用:=遇到的坑
  18. MAC下Xcode配置opencv(2017.3.29最新实践,亲测可行)(转)
  19. Android基础笔记(九)- 广播
  20. 【Git】Git与GitHub 入门

热门文章

  1. 转linux文件的读写
  2. 内网使用 IPV6 之 TunnelBroker隧道(6in4)篇
  3. setting.system-全局属性的设定
  4. 二叉树的递归插入【Java实现】
  5. opencv cvPreCornerDetect
  6. 【河南省多校脸萌第六场 E】LLM找对象
  7. 前端开发概述+JS基础细节知识点
  8. POJ 3187 Backward Digit Sums 枚举水~
  9. 【CS Round #48 (Div. 2 only)】Water Volume
  10. OC学习篇之---类的定义