Skip to content

Instantly share code, notes, and snippets.

@peterblazejewicz
Created July 18, 2022 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterblazejewicz/60fe0c49d5dbae797f47dd3d50057516 to your computer and use it in GitHub Desktop.
Save peterblazejewicz/60fe0c49d5dbae797f47dd3d50057516 to your computer and use it in GitHub Desktop.
Infer string literal
interface ApiData {
'maps:longitude': string;
'maps:latitude': string;
}
type RemoveMapsFromData<T> = {
[K in keyof T as RemoveMaps<K>]: T[K];
};
type ExpectedApiData = RemoveMapsFromData<ApiData>;
type RemoveMaps<T> = T extends `maps:${infer U}` ? U : T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment