Alias

    TIL | Interface VS Type

    Interface VS Type Alias Interface 인스턴스를 생성하는 class 처럼, 특정한 규칙을 담고 있는 것을 구현할 때 사용하는 것이 적절하다. 1. 기존에 존재하는 인터페이스의 프로퍼티 확장 interface Person { name: string; age: number; } // interface Person { gender: string; } // const yongmin: Person = { name: "yongmin", age: 29, gender: "male", }; 기존 존재하던 인터페이스에 새로운 프로퍼티를 추가할 수 있다. 동일한 이름의 인터페이스에 추가하고자 하는 프로퍼티 값만 적어주면 된다. (공식문서에서는 동일한 인터페이스가 존재할 경우, 해당 필드값들을 merg..

    TIL | Alias

    Alias Alias - primitive type type Text = string; // string을 Text라는 타입으로 지정 const name: Text = "Yongmin"; // type Num = number; // number를 Num이라는 타입으로 지정 const age: Num = "29"; 위처럼 원하는 타입 명으로 타입을 직접 지정할 수 있다.(ex> Text, Num) Alias - object type type Text = string; type Number = number; / type Student = { name: string; // (property) name: string age: number; // (property) name: number }; // const s..