[Typescript] 11. Medium - Equal
Implement the Equal<T, U>
For example:
type isEqual = Equal<1, 1> // true
Idea:
Parameter type:
<P>(x: P) => any
Check P extends T ? 1: 2
Then check P extends U ? 1 : 2
Then see whether 1 extends 1 or 2 extends 2? then true
If 1 extends 2 or 2 extends 1 then false
type Equal<T, U> =
(<P>(x: P) => P extends T ? 1: 2) extends
(<P>(x: P) => P extends U ? 1: 2)
? true
: false