Refactor type

I got a type def -
// Clear this mess
type GeneralCondition<T extends ValidSubscription> = {
[K in T as T extends SubWithoutBroadcasterId
? never
: "broadcaster_user_id"]: string;
} & {
[K in T as T extends `user.${string}` ? UserAuthSubCondition : never]: string;
} & {
[K in T as T extends "channel.raid"
? "from_broadcaster_user_id" | "to_broadcaster_user_id"
: never]: string;
} & {
[K in T as T extends "channel.follow" | `channel.guest_star_${string}.update`
? "moderator_id"
: never]: string;
} & {
[K in T as T extends
| `channel.channel_points_custom_reward_redemption.${string}`
| `channel.channel_points_custom_reward.${"update" | "remove"}`
? "reward_id"
: never]: string;
} & {
[K in T as T extends "drop.entitlement.grant"
? DropEntitlementGrantCondition
: never]: string;
} & {
[K in T as T extends `extension.${string}`
? "extension_client_id"
: never]: string;
};
// Clear this mess
type GeneralCondition<T extends ValidSubscription> = {
[K in T as T extends SubWithoutBroadcasterId
? never
: "broadcaster_user_id"]: string;
} & {
[K in T as T extends `user.${string}` ? UserAuthSubCondition : never]: string;
} & {
[K in T as T extends "channel.raid"
? "from_broadcaster_user_id" | "to_broadcaster_user_id"
: never]: string;
} & {
[K in T as T extends "channel.follow" | `channel.guest_star_${string}.update`
? "moderator_id"
: never]: string;
} & {
[K in T as T extends
| `channel.channel_points_custom_reward_redemption.${string}`
| `channel.channel_points_custom_reward.${"update" | "remove"}`
? "reward_id"
: never]: string;
} & {
[K in T as T extends "drop.entitlement.grant"
? DropEntitlementGrantCondition
: never]: string;
} & {
[K in T as T extends `extension.${string}`
? "extension_client_id"
: never]: string;
};
ValidSubscription, DropEntitlementGrantCondition. SubWithoutBroadcasterId, UserAuthSubCondition are an union of strings Is there a way i can make this better
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server