-
Notifications
You must be signed in to change notification settings - Fork 141
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
Argument of type Record<string, string>
is not assignable to parameter of type Traits | Callback | null | undefined
#575
Comments
@zygopleuralI Thanks for taking out an issue. I wasn't able to reproduce -- // This works
const traits: Record<string, string> = {name: "hello"}
analyics.identify("foo", traits) FYI, the definition of JSONValue already contains // This works
const traits: Record<string, JSONValue | string | number> = {name: "hello"};
analytics.identify("foo", traits) Is there a more advanced type you're having problems with? |
@zygopleural Thank you for the detail, that's an interesting one, and will be a problem if anyone attempts to coerce an object created with that pattern to a Record type. For now, you can fix by casting traits to "object" or by creating a type UserTraits = {
name: string
age: string
}
const { id, picture, signInMethod, ...traits } = user
identify(id, traits as UserTraits) |
@zygopleural fixed in |
FYI @zygopleural there is an open Typescript issue about this scenario / bug: microsoft/TypeScript#48014 |
Ah nice find! |
Breaking change introduced
I have a breaking change trying to upgrade 1.41.0 -> 1.42.1
Expected
I should be able to pass any
Record<string, string | number | JSONValue>
as traits into theidentify
call.Actual
I can only only pass
Record<string, JSONValue>
Culprit
Looks like here was a breaking change in @segment/[email protected]
I believe #561 is the culprit, specifically these changes
The text was updated successfully, but these errors were encountered: