작성한 질문수
실전 연습으로 익히는 고급 타입스크립트 기술
Array indexing
해결된 질문
작성
·
196
1
감사합니다.
const rgb = ["red", "green", "blue"] as const; type RedAndBlue = (typeof rgb)[0 | 1]; type RGB = (typeof rgb)[0 | 1 | 2]; type tests = [ Expect<Equal<RedAndBlue, "red" | "green">>, Expect<Equal<RGB, "red" | "green" | "blue">> ];
답변 1
0
type RGB = typeof rgb[number]
RGB는 위처럼 해도 될 것 같네요