✔️ Type Aliases

  • 기존 데이터 타입에 사용자 정의 이름 부여
  • 코드 가독성 향상
  • 복잡한 타입 구조 단순화


// primitive data type
type Name = string;
const myName: Name = "myKuromi";

// object type
type Me = {
	name: string,
    level: number
};
const me: Me = {
	name: "myKuromi",
    level: 99
};

// function 
type HelloFunction = (name: string) => string;
const hello: HelloFunction = (name) => `Hello, ${name}!`;

 

'TypeScript' 카테고리의 다른 글

Deep Dive : 타입스크립트  (0) 2024.05.25
TypeScript data type & function  (0) 2024.02.04
TypeScript basic  (0) 2024.02.04

+ Recent posts