generated from capacitor-community/.github
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(type): fix ValidateAllEventsEnumAreImplemented
- Loading branch information
Showing
1 changed file
with
21 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import type { PluginListenerHandle } from '@capacitor/core'; | ||
|
||
|
||
type Contra<T> = (x: T) => void | ||
type UnwrapContra<T> = [T] extends [Contra<infer S>] ? S : never | ||
type UnionToIntersection<U> = UnwrapContra<U extends any ? Contra<U> : never> | ||
|
||
type Overload<T> = | ||
(eventName: T, listenerFunc: (...args: any[]) => any) => PluginListenerHandle | ||
type OverloadUnionForEnum<T> = T extends any ? Overload<T> : never | ||
|
||
type OverloadUnion<T> = OverloadUnionForEnum<T> | ||
// Overload<RewardAdPluginEvents.FailedToLoad> | Overload<RewardAdPluginEvents.Dismissed> | Overload<RewardAdPluginEvents.Rewarded> | ||
|
||
type Overloads<T> = UnionToIntersection<OverloadUnion<T>> | ||
|
||
export type ValidateAllEventsEnumAreImplemented<TEventsEnum, TDefinitionInterface extends { addListener: Overloads<TEventsEnum> }> = TDefinitionInterface; | ||
import type { PluginListenerHandle } from '@capacitor/core'; | ||
|
||
type Contra<T> = (x: T) => void; | ||
type UnwrapContra<T> = [T] extends [Contra<infer S>] ? S : never; | ||
type UnionToIntersection<U> = UnwrapContra<U extends any ? Contra<U> : never>; | ||
|
||
type Overload<T> = ( | ||
eventName: T, | ||
listenerFunc: (...args: any[]) => any, | ||
) => Promise<PluginListenerHandle>; | ||
type OverloadUnionForEnum<T> = T extends any ? Overload<T> : never; | ||
|
||
type OverloadUnion<T> = OverloadUnionForEnum<T>; | ||
// Overload<RewardAdPluginEvents.FailedToLoad> | Overload<RewardAdPluginEvents.Dismissed> | Overload<RewardAdPluginEvents.Rewarded> | ||
|
||
type Overloads<T> = UnionToIntersection<OverloadUnion<T>>; | ||
|
||
export type ValidateAllEventsEnumAreImplemented< | ||
TEventsEnum, | ||
TDefinitionInterface extends { addListener: Overloads<TEventsEnum> }, | ||
> = TDefinitionInterface; |