해결된 질문
작성
·
175
0
import { Equal, Expect } from "./helper";
export const Color = {
Red: "red",
Green: "green",
Blue: "blue",
} as const;
type RedGreenBlueValue =
| (typeof Color)["Red"]
| (typeof Color)["Blue"]
| (typeof Color)["Green"];
type tests = [Expect<Equal<RedGreenBlueValue, "red" | "blue" | "green">>];
답변 1
0
export const Color = {
Red: "red",
Green: "green",
Blue: "blue",
} as const;
type ColorType = typeof Color
type RedGreenBlueValue = ColorType[keyof ColorType];
네 그렇게 하셔도 되고 이렇게 해도 될 것 같네요?