posthog-js-lite icon indicating copy to clipboard operation
posthog-js-lite copied to clipboard

Incorrect types on `personProperties` for `getAllFlags`

Open xmonkee opened this issue 6 months ago • 5 comments

Bug description

personProperties is typed as Record<string, string> whereas it should be Record<string, string | number>

How to reproduce

Try to call getAllFlags with a numerical personProperty and you will get a type error

image

Related sub-libraries

  • [ ] All of them
  • [ ] posthog-web
  • [x] posthog-node
  • [ ] posthog-react-native

Additional context

posthog-node version 3.6.3

xmonkee avatar Feb 27 '24 23:02 xmonkee

The JS SDK is defined as:

export type Property = any
export type Properties = Record<string, Property>

@neilkakkar should it be similar to the JS SDK or was it intended to be <string, string>?

marandaneto avatar Feb 28 '24 10:02 marandaneto

oh I seem to have overlooked this. We can & should accept numbers too indeed 👍

neilkakkar avatar Feb 28 '24 11:02 neilkakkar

oh I seem to have overlooked this. We can & should accept numbers too indeed 👍

@neilkakkar would you like/do you have time to take a stab at it before we release the next major? not sure if this is a breaking change, since Record<string, Property> will still be compatible with <string, string>.

marandaneto avatar Mar 04 '24 08:03 marandaneto

sigh want to but don't seem like I have the time with all the incident fixes :/

neilkakkar avatar Mar 04 '24 16:03 neilkakkar

Yeah wouldn't be breaking, will relax types in all functions

neilkakkar avatar Mar 04 '24 16:03 neilkakkar