블로그
메모
const theme = {
colors: {
primary: "#ffb266",
fontColor: "#4d5256",
disabled: "#c0c0c0",
black: "#000",
white: "#fff",
},
} as const;
export default theme;
// type Keys = keyof typeof theme.colors; // "primary" | "fontColor" | "disabled" | "black" | "white"
// theme[keyof typeof theme]; // ffb266 | 4d5256 | ...
export type ITheme = typeof theme;
// // 1번 가능하고
// type ThemeInterface = typeof theme[keyof typeof theme];
// // 2번 가능하고
// type ThemeInterface = typeof theme
// // 3번 가능하고
// type ThemeInterface = Theme[keyof Theme];
type ValueOf<T> = T[keyof T];
export type TagMapValueType = ValueOf<typeof TagMap>;
export type TagMapValueType2 = typeof TagMap[keyof typeof TagMap];
// https://stackoverflow.com/questions/49285864/is-there-a-valueof-similar-to-keyof-in-typescript