nytimes / react-tracking

🎯 Declarative tracking for React apps.
https://open.nytimes.com/introducing-react-tracking-declarative-tracking-for-react-apps-2c76706bb79a
Other
1.88k stars 123 forks source link

Update @types/react-tracking #172

Open Sicria opened 3 years ago

Sicria commented 3 years ago

Is it possible to update the types for the useTracking hook to allow for passing in an object.

tizmagik commented 3 years ago

Yes, that'd be great. TypeScript types via DefinitelyTyped, @types/react-tracking, are a community-driven effort currently. Although we do have plans to rewrite the internals to TypeScript and thus export type definitions directly (see #152 for WIP or if you'd like to contribute)

Also as noted in #173 by @mattes3:

the typescript types are not up to date. They correspond to version 7. They are missing the property Track in the object that is returned by the useTracking() hook.

trescenzi commented 2 years ago

Hi all. I ran into an issue where, in TS, I couldn't pass a function as the first argument to useTracking and then in turn use the return value of that function in dispatch. I opened a PR(linked above) and I believe that it's accurate. Not 100% but I've already made the changes in my project's d.ts file and everything is working as expected. Let me know if there's anymore information you'd like or if there's more I could do here.

Thank you! Love the library.

trescenzi commented 2 years ago

Just wanted to bump this. I've gotten approval from the definitivelytyped maintainers but will wait till the evening of 5/3, or someone here says otherwise, to merge it in case anyone from this repo has opinions on the change. I've got the changes locally running on a production site so I'm pretty certain it's safe, just want to make sure the owners of this repo don't have any issues with it.

tizmagik commented 2 years ago

Those updates look good @trescenzi -- thanks so much for contributing. It's greatly apprecaited!