Open utterances-bot opened 2 years ago
Thanks for this article, but there are some cases in which this solution doesn't work. I know it from this link: https://stackoverflow.com/a/59687759
@EmmaammE yeah, there are some cases when the community adds more test cases after I've solved them and explained. Which brings more requirements and (sometimes) breaks the solution. That's why comments exists 😺
Thanks for the link and letting us know 👍🏻
Updated solution for new test case:
type newTestCase = Expect<Equal<IsUnion<never>, false>>
type IsUnion<T, C = T> =
[T] extends [never]
? false
: T extends T
? [C] extends [T]
? false
: true
: never
IsUnion
This project is aimed at helping you better understand how the type system works, writing your own utilities, or just having fun with the challenges.
https://ghaiklor.github.io/type-challenges-solutions/en/medium-isunion.html