[[as const]]가 붙여진 `Color` 에서 [[Union|pipe symbol]] 로 특정 property 를 접근하면 결과는 [[String literal type]]이 리턴된다.
```typescript
export const Color = {
Red: "red",
Green: "green",
Blue: "blue",
} as const
type RedAndBlue = typeof Color["Red" | "Blue"]
// expected: "red" | "blue"
```
---
마찬가지로 array에서 숫자를 index로 접근해서 새로운 타입(`RedAndBlue`, `RGB`)을 생성할 수 있다.
```typescript
const rgb = ["red", "green", "blue"] as const;
type RedAndBlue = typeof rgb[0 | 1];
//expected: "red" | "green"
type RGB = typeof rgb[number];
//expected: "red" | "green" | "blue"
```
---
참조 강의: https://inf.run/FVDi