Clerk - can’t get types of unsafeMetadata properties on user object?

I have some unsafeMetadata stored on the user object for users in my t3-app. When I try to access any property of the object, TypeScript seems unable to get/infer the type of that property. So for example: user.unsafeMetadata.stringProperty should be a string but it comes back as unknown. Is this a known issue or am I not doing something right?
3 Replies
.traevelliath
.traevelliath17mo ago
AFAIK, clerk does not and cannot know, what type of custom metadata it would be. So you have to assert them manually with overloading or 'as string'.
zendev
zendev17mo ago
Hmm ok the way it looks in the Clerk dashboard does make it look like it knows the types (strings are surrounded by quotes, booleans and numbers aren’t) but maybe I’m wrong. I’ll keep using type assertions for now then 👍🏽
.traevelliath
.traevelliath17mo ago
Yeah, I mean when you set it in clerk dashboard, clerk has a hint on what type of data you gave it. But clerkClient, when you fetch from server, cannot not know if the data in custom metadata on a specific user on which it has nothing yet even exist. So yeah, manual assertion is the way I guess.
Want results from more Discord servers?
Add your server