diff options
Diffstat (limited to 'src/alf/types.ts')
-rw-r--r-- | src/alf/types.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/alf/types.ts b/src/alf/types.ts new file mode 100644 index 000000000..76ac05d40 --- /dev/null +++ b/src/alf/types.ts @@ -0,0 +1,16 @@ +type LiteralToCommon<T extends PropertyKey> = 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<T> = { + -readonly [K in keyof T]: T[K] extends PropertyKey + ? LiteralToCommon<T[K]> + : Mutable<T[K]> +} |