Is it possible to define a type that does this?
I'm trying to define a morph that turns the presence of a string key into true and the absence of the key results in false.
In the below, I can't work out how to define myType to get the result I want, or if it's even possible?
To deal with the possible absence of the 'approved' key, I've tried to add a default, but then I can't apply a morph to turn it into a Boolean. If I don't apply a default but make it optional, then it ignores the approved key for secondObject.
Am I missing something or is this not possible?
3 Replies
I guess something likeshould work
(I can't remember if the params are
value, ctx or ctx, value, so you might need to swap them)Damn, that's so obvious, thanks! It didn't occur to me to .pipe the entire type like that. I was trying to apply the morph within the definition of the '"approved" key instead. Much simpler this way!
Fwiw, you can one-line the return too