Created
May 16, 2023 16:41
-
-
Save wolak041/59778b74966098c11acc9f02f0c53294 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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