journal 20260203

markdown Today is my Plank workout day 3, I can hold in `02:01` second, I will continue do it. I starting to make probiotics live in my body, so I take `NOW Foods` 's Probiotic-9 50Billion. I hope I can overcome the milk digestion issue. I refactor my company code with follow: ```ts // old export const LinkTypes = ['facebook', 'youtube', 'instagram', 'linkedin', 'x'] as const; export type LinkType = typeof LinkTypes[number]; ``` ```ts // new export const LinkType = {   Facebook: 'facebook',   Youtube: 'youtube',   Instagram: 'instagram',   Linkedin: 'linkedin',   X: 'x', } as const; export type LinkType = typeof LinkType[keyof typeof LinkType]; export const LinkTypes = Object.values(LinkType) as readonly LinkType[]; ``` It can compatible with old usage like `const link: LinkType = 'facebook'`. Also can use readable and no typing string like `const link: LinkType = LinkType.Facebook`. In our dto can compatible with @IsIn(LinkTypes). This is good cuz I can replace part of our codebase step by step and not need to worry about change everywhere it use 'facebook'. This is why I use this method instead of Enum. because Enum can not compatible like this `foo('youtube')` or `if (obj.type === 'youtube')`, once I miss somthing the server will not be build or crash on runtime. BTW: I eat kimbap with my wife today.

留言

這個網誌中的熱門文章

成人剪舌繫帶聽過嗎?我剪了!!

關於RCA

睡覺使你更有效率