DEV Community

Discussion on: TypeScript Exercises Bonus🦠 - Answers Part 1

Collapse
 
dvlden profile image
Nenad Novaković

My solution to #1 is way simpler:

type CanMeet<A extends Patient, B extends Patient> = A['state'] extends B['state'] 
  ? true 
  : false
Enter fullscreen mode Exit fullscreen mode

At least it passes all given conditions.
I was unable to solve #2 and #3.

Collapse
 
macsikora profile image
Pragmatic Maciej

Ye you have nail that as the false is only when we have different states. That is very good answer 👍

Collapse
 
arthurka profile image
ArthurKa • Edited

I guess it's better not to bind the implementation to discriminated field value (state). It should remain variable.