Last active
February 22, 2023 13:36
-
-
Save davlet61/61ff6bc39fdcb1c4d02c990b7198d55b to your computer and use it in GitHub Desktop.
Revisions
-
davlet61 revised this gist
Feb 22, 2023 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,9 @@ type SnakeToCamelCase<T> = T extends `id${infer S}_${infer N}` ? `${F}${Capitalize<N>}` : T; type MappedType<T> = { [K in keyof T as SnakeToCamelCase<K>] : T[K] }; /* This is a specific case where some of the snake case types start with `ids`. The snippet can be easily modified for any use case. */ -
davlet61 renamed this gist
Feb 22, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davlet61 renamed this gist
Jan 31, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davlet61 created this gist
Jan 31, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ type SnakeToCamelCase<T> = T extends `id${infer S}_${infer N}` ? `${SnakeToCamelCase<N>}Id${S}` : T extends `${infer F}_${infer N}` ? `${F}${Capitalize<N>}` : T; type MappedType<T> = { [K in keyof T as SnakeToCamelCase<K>] : T[K] };