We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useTrackEvent doesn't have the same typing as the useGtag()('event', ....nicely typed args)
useGtag()('event', ....nicely typed args)
I tried to implement this but didn't get far with it. Not easy when I only have the GTag type to work with.
import type { Gtag } from '../types' import { useGtag } from './useGtag' type Event = Gtag | ((command: 'event') => never) type OmitCommandParameter<T> = T extends (command: 'event', ...rest: infer R) => void ? (...args: R) => void : never export function useTrackEvent( eventName: Parameters<OmitCommandParameter<Event>>[0], eventParams?: Parameters<OmitCommandParameter<Event>>[1], ) { const { gtag } = useGtag() gtag('event', eventName, eventParams) }
Perhaps other types can be exported too? It would make sense in case someone constructs the arguments outside of a function call.
The text was updated successfully, but these errors were encountered:
d57cbd5
Valid point! Thanks for the hint and verbose issue description. 🙂
Sorry, something went wrong.
No branches or pull requests
Describe the feature
useTrackEvent doesn't have the same typing as the
useGtag()('event', ....nicely typed args)
I tried to implement this but didn't get far with it. Not easy when I only have the GTag type to work with.
Perhaps other types can be exported too?
It would make sense in case someone constructs the arguments outside of a function call.
Additional information
Final checks
The text was updated successfully, but these errors were encountered: