#author("2020-06-14T02:05:13+09:00","default:ryuichi","ryuichi")
#author("2020-06-14T02:28:52+09:00","default:ryuichi","ryuichi")
* Interface vs Type [#s746d140]
- TSのバージョンアップに伴い、機能に違いはほとんどなくなったので、どっちでもいい。
- 型宣言のマージ(Declaration Merging)をしたい時はInterfaceを使う。
*** 型宣言のマージ [#xb4aa6dd]
interface Point { x: number; }
interface Point { y: number; }
const point: Point = { x: 1, y: 2 };
- 2つのPointインターフェイスがマージされて、xとyを共に取るインターフェイスになっている
** 参考 [#q4647145]
https://stackoverflow.com/questions/37233735/typescript-interfaces-vs-types