Skip to content

Commit

Permalink
Inlining type
Browse files Browse the repository at this point in the history
  • Loading branch information
4lejandrito committed Aug 5, 2024
1 parent c3d4a91 commit eaae127
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/usePlausible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ type EventOptions<P extends Props> = {
u?: string
callback?: VoidFunction
}
type EventOptionsTuple<P extends Props> = [P] extends [never]
? [Omit<EventOptions<P>, 'props'>?]
: [EventOptions<P>]
type Events = { [K: string]: Props }

export default function usePlausible<E extends Events = any>() {
return useCallback(function <N extends keyof E>(
eventName: N,
...rest: EventOptionsTuple<E[N]>
...rest: [E[N]] extends [never]
? [Omit<EventOptions<never>, 'props'>?]
: [EventOptions<E[N]>]
) {
return (window as any).plausible?.(eventName, rest[0])
},
Expand Down

0 comments on commit eaae127

Please sign in to comment.