在typescript中有两种类型生命方式,interface
和type
,本文将介绍将介绍interface
和type
在声明时的不同。
interface可以重复声明,typescript会将他们合并。
1 | interface Box { |
而type不可重复声明。
1 | type Box { |
interface
能用于extends或者implements
,而type
不可以。
An interface may only extend a class or another interface.
A class may only implement another class or interface.
- 本文链接: https:https://whyour.cn/post/typescript-types-vs-interfaces.html
- 最后更新于:
- 版权声明: 本博客所有文章除特别声明外,均采用 署名 4.0 国际(CC BY 4.0) 许可协议。转载请注明出处!
使用typescript和html开发vue
hexo博文摘要生成方案