인덱스 타입

N·2023년 2월 2일

typescript

목록 보기
7/7
  • 타입을 동적으로 받을 때 사용할 수 있다
interface ObjType = {
  [key: string]: string;
};

export const conditions: ObjType = {
  all: '전체',
  inProgress: '진행중인투표',
  terminate: '종료된투표',
};
  • 인덱스 시그니처(key)에는 string이나 number만 들어갈 수 있다
profile
web

0개의 댓글