Require one of two properties
What would you folks say is a clean way to accomplish that either
userToken or ConversationId are set in my type without requiring both? π€
14 Replies
Interesting question, it seems like no matter what we do, it won't be 100%, but you can achieve it like this:

but no matter what I try, it'll always show the other one:

But at least you get an error if you do fill it

I need to use that logic in like 10 different types for a lot of my request models, I'll try this suggestion but seems a bit ugly to have to add both types to all the types π€
@deforestor what do you think about this?
And then I just do & ConversationIdOrUserToken to all of them.
I tried that one too, but..

it doesn't show me the error
How about this?
Could probs be turned into a helper
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
I think itβs from another SO, looks the same tho
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
Wouldn't what I sent earlier work?
And then I just do & ConversationIdOrUserToken to all of them.
can you show how it looks on the editor?
