Skip to content
New issue

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

TypeScript types don't allow numbers in set_once #179

Open
garybernhardt opened this issue Dec 12, 2020 · 0 comments
Open

TypeScript types don't allow numbers in set_once #179

garybernhardt opened this issue Dec 12, 2020 · 0 comments

Comments

@garybernhardt
Copy link

In the types, set can take a number:

    set(distinctId: string, propertyName: string, value: string | number, callback?: Callback): void;

but set_once can't:

    set_once(distinctId: string, propertyName: string, value: string, callback?: Callback): void;

I can work around this by using a different overload of the function (the one that takes a properties object). But why this difference?

This seems to be part of a consistent trend in Mixpanel's type definitions: they seem like a hasty afterthought. For example, the PropertyDict type is defined as {[key: string]: any}, which will accept any object, including objects containing values that Mixpanel definitely can't handle. In fact, it will happily accept objects that aren't even serializable to JSON! These type definition defeat much of the value of using types. They can't stop users from making most of the errors that would actually matter. (But the set_once bug will prevent users from setting properties to number values.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant