タイプAliasとインタフェース
2746 ワード
比較
共通点
// 인터페이스의 상속
interface AInterface extends BInterface {}
// type alias의 상속
type AType = Btype & { a: number}
Only Interface
interface A {
name: string;
}
interface A {
age: number;
}
const obj: A = {
// A interface가 다중으로 선언되었고, 이것으로 A는 merge 된다.
// 따라서 A를 사용하기 위해서는 name과 age 모두 구현해야 한다.
}
Only Type Alias
type Direction = 'left' | 'right' | 'up' | 'down';
何を使うべきですか。
Interface
interface
を使用します.interface
「このインタフェースを実装するクラスはありますか?」こんな思いをさせられる.Types (type alias)
type alias
を使用します.Reference
この問題について(タイプAliasとインタフェース), 我々は、より多くの情報をここで見つけました https://velog.io/@with-key/Type-Alias-와-Interfaceテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol