Skip to content

Instantly share code, notes, and snippets.

@wolak041
Created May 16, 2023 16:41
Show Gist options
  • Save wolak041/59778b74966098c11acc9f02f0c53294 to your computer and use it in GitHub Desktop.
Save wolak041/59778b74966098c11acc9f02f0c53294 to your computer and use it in GitHub Desktop.
interface Messenger {
sendText: () => void;
sendFile: () => void;
checkStatus?: () => void;
}
type RequiredFields<T> = {
[K in keyof T as T[K] extends Required<T>[K] ? K : never]: T[K];
};
// type RequiredMessengerProperties = {
// sendText: () => void;
// sendFile: () => void;
// }
type RequiredMessengerProperties = RequiredFields<Messenger>;
type FeatureOptions<T> = {
[K in keyof T as `is${Capitalize<K & string>}Enabled`]: boolean;
};
// type FeatureFlags = {
// isSendTextEnabled: boolean;
// isSendFileEnabled: boolean;
// }
type FeatureFlags = FeatureOptions<RequiredMessengerProperties>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment