mixpanel / mixpanel-js

Official Mixpanel JavaScript Client Library
https://mixpanel.com/help/reference/javascript
Other
867 stars 309 forks source link

TypeScript Error: Property 'track_pageview' does not exist on type 'OverridedMixpanel'. - v2.47.0 #379

Open beforeoafterm opened 1 year ago

beforeoafterm commented 1 year ago

Hi, all!

I'm currently using React (^18.1.0) with TypeScript (^5.0.4) and mixpanel-browser (^2.47.0).

Using the new track_pageview() method in the latest release, however, I am encountering this TS error:

Property 'track_pageview' does not exist on type 'OverridedMixpanel'.
Screenshot 2023-05-31 at 1 11 30 PM

When I checked mixpanel/index.d.ts, it looks like the Mixpanel interface does not have the method signature defined for track_pageview().

Screenshot 2023-05-31 at 1 14 42 PM

I believe we can fix this issue for TS users by adding the method signature:

track_pageview(properties?: Dict): void
tdumitrescu commented 1 year ago

It looks like these are types from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/mixpanel-browser/index.d.ts. That repo would probably be the right place to submit updates.

khanhtn91 commented 1 year ago

Same issue

beforeoafterm commented 1 year ago

Opened a new discussion on the DefinitelyTyped repo for this here: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65666

cotarelorodrigo commented 11 months ago

Same problem. I need a solution to track page view in browser...

tdumitrescu commented 11 months ago

Looks like this was already merged? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65672

cotarelorodrigo commented 11 months ago

But mixpanel needs to update mixpanel-browser version?

Looks like this was already merged? DefinitelyTyped/DefinitelyTyped#65672

tdumitrescu commented 11 months ago

But mixpanel needs to update mixpanel-browser version?

If the new types haven't been published yet, I'd guess that's something to take up with https://github.com/DefinitelyTyped/DefinitelyTyped