type LiteralToCommon = T extends number ? number : T extends string ? string : T extends symbol ? symbol : never /** * @see https://stackoverflow.com/questions/68249999/use-as-const-in-typescript-without-adding-readonly-modifiers */ export type Mutable = { -readonly [K in keyof T]: T[K] extends PropertyKey ? LiteralToCommon : Mutable }