Enum 예제

旅人·2023년 4월 26일
0

Example Code

// enums
enum ResourceType {
  BOOK,
  AUTHOR,
  FILM,
  DIRECTOR,
  PERSON,
}

interface Resource<T> {
  uid: number;
  resourceType: ResourceType;
  data: T;
}

const docOne: Resource<object> = {
  uid: 1,
  resourceType: ResourceType.BOOK, // 0
  data: { title: "name of the wind" },
};

const docTwo: Resource<object> = {
  uid: 10,
  resourceType: ResourceType.PERSON, // 4
  data: { name: "Jack" },
};

참고

https://www.youtube.com/watch?v=r8G7-hQG07o&list=PL4cUxeGkcC9gUgr39Q_yD6v-bSyMwKPUI&index=19

profile
一期一会

0개의 댓글